Leonard
Leonard

Reputation: 79

image from java serverlet to another jsp

My problem is when i retrieve some strings from mydemo.java in my GET method of index.jsp with this form :

 <form method="get" action ="${pageContext.request.contextPath }/myserverlet?">

 name:   <input type = "text"  name = "nome" placeholder = "name" value="${name}" ><br><br>
  etc .... ... 

he takes these values from /myserverlet and returns an image from concatenated strings like following :

 String v_card = String.format("%s%n%s%n%s%n%s%n%s%n%s", header_info,name, company, tel,mail,footer);

That's ok , but , my problem is: how can i pass this image that he retrieves from /servelet to another jsp page and not index.jsp ? should i do something in "myfile2.jsp"?

Upvotes: 0

Views: 71

Answers (1)

Eshu
Eshu

Reputation: 519

You can try with hidden field

<input type="hidden" name="v_card" value="${v_card}"> 

And then you can pass that using

session.setAttribute("v_card", v_card);

Now as long as your session is active you can retrieve the value in any jsp

String v_card = session.getAttribute("v_card");

After that you can assign this value to image tag to display the image

Upvotes: 1

Related Questions