-1

I have a jsp page where am displaying image (which is generated in servlet and passed with name in jsp) and accepting text. Now i would like to pass that image tag value and textarea value to another jsp page. I am able to get textarea value but how to retrieve image to servlet.

JSP code:

<form id="form1" action="CallServlet">
<img src="PieChartDemo" width="600" height="400" border="0" name="chartsample"/><br>
<textarea rows="4" cols="150" id=t1 name=t1></textarea>
<input type="Submit" value="Send"/>
</form>

Servlet Code:

PrintWriter out=response.getWriter();
PieChartDemo pcd=new PieChartDemo();
String textvalues=request.getParameter("t1");
System.out.println("Text values : "+textvalues);
out.println(textvalues);

Now i would like to display or store it into a variable that image. How to go about? Suggest.

Thanks in Advance.

Shoaib Chikate
  • 8,665
  • 12
  • 47
  • 70
Pallavipradeep
  • 101
  • 1
  • 2
  • 14
  • You want the actual binary content of the image? Why not set some values on the session and read them in the other JSP? – mplungjan Apr 14 '14 at 06:39
  • Hi Sotirios, Thank you for response. But could you please suggest how to store that value, because am calling a chart here which is calculated in servlet1(calculation)--> jsp(image,textarea)-->servlet2. Here jsp is showing that chart which is calculated in servlet1, remaining flow i have specified in code – Pallavipradeep Apr 14 '14 at 06:42
  • Who are you asking what? I asked: Do you need the actual binary image data? – mplungjan Apr 14 '14 at 07:34
  • Hi sir, Yes i require actual binary image data. – Pallavipradeep Apr 14 '14 at 09:04
  • http://stackoverflow.com/questions/4998908/convert-data-uri-to-file-then-append-to-formdata – mplungjan Apr 14 '14 at 09:37
  • Thank you this was helpful when i would like to store it in blob and extract it. – Pallavipradeep Apr 14 '14 at 11:43

1 Answers1

1

you can not upload files using getParameter method.
for that u will have to use apache file upload.

Just go through the following link it will definatley solve your problem.

servlets-file-uploading

Mitul Maheshwari
  • 2,647
  • 4
  • 24
  • 38