I want to display the image located in my local drive. I am using sun java app server 8. For example If I generate a file abc.jpg dynamically and store it in c:\abc.jpg, then how could I use it in jsp or servlets? How to display it in the jsp or servlet pages?
I know giving the path c:\abc.jpg in coding to display image wont work , because it is out of webserver..
I want to display the image located in my local drive. I am using
Share
Basically just create a
Servletwhich gets anInputStreamof it with help ofFileInputStreamand writes it to theOutputStreamof theHttpServletResponsealong with a correct set of response headers with at least thecontent-type. Finally call this servlet in thesrcattribute of the<img>element along with the file identifier as request parameter or pathinfo. E.g.:You can find here a complete basic example: http://balusc.blogspot.com/2007/04/imageservlet.html