I have to show some data and image in the forwarded JSP
To show data I have set the value in the attribute section
request.setAttribute("data", mydata);
I have the image in stream (InputStream) and I can save it as a file too but would like to know if there is a better way of streaming it directly to JSP page.
If I save it using the servlet temp directory “javax.servlet.context.tempdir” then I cannot access it either through
<img src="location of the file set in attribute section"/>
Any preferred way other’s have tried?
Using Tomcat 7.0.33/Java 7
HTTP doesn’t really let you stream images per se, but you could achieve this by piping the data from your
InputStreamtoHttpServletResponse.getOutputStream().You could have a servlet that is mapped to image files, something like…
And then the servlet class itself can handle the image data stream without having to save it to a file. Something like…
Then the page could just have regular image tags in it.