Web tier: servlets, JSP, Web frameworks: Rendering the image in a web application
Hi, I'm receiving an encoded image from a webservice. I need to decode it and display it in the JSP. I have the decoding logic in place (its base 64 one). With every request, a fresh image will be created. To display the image in the JSP, I need to have the decoded image in the server and in JSP I need to point to the location where it is stored. Just wanted to know if there is any better way. Also, I don't want to load the server with images, so I need to have a thread to delete those images at regular intervals. Suggestions on naming the image file are welcome, to make sure that there's no duplication and the right image is rendered to the user. Thanks very much in advance.
- Posted by: Prasanna Hegde
- Posted on: September 20 2007 11:33 EDT
- Re: Rendering the image in a web application by Andy Leung on September 20 2007 14:41 EDT
Solution #1: You can put the image stored as byte in session. You will have a controller that is designated to send this image in bytes when it is requested from the JSP. Solution #2: You can put this image on local storage like temp folder. Then you this image by generating the URL. Solution #3: Store the image in database so you don't have to worry about naming convention. Once you retrieve this image from database you delete it immediately so you don't need to have a separate thread to delete it.
Hi, First solution looks better in me in this case case. Is any way to pass the image bytes to the servlet (or JSP) without using the session?
See for example Temp objects taglib in Coldtags suite: http://www.servletsuite.com/jsp1.htm
hi,i have the same requirement,could you please help me out how to start with.