This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Another possibility would be to create an action that gets a single image from the database by specimen Number and writes it to the outputStream of the HttpServletResponse object with the header set to the proper MIME type. Or even easier: extend the org.apache.struts.actions.DownloadAction class provided by Struts.
Then within the loop in your JSP, use the html:img tag to call the action and display the image.
Merril: When I try to add the action part to <html:img> tag:
I get this error in compile:
I use struts 2 by the way. How can I fix this?! (as you can see I'm a greenhorn!)
Jeanne: If I want to choose this approach, how can I take care of deleting those images from the file system afterward? I think after some queries there will be many images left uncared in the file system. How can I deal with them? If I can trust the users to always click "logout", I think I can take care of deleting those temporary images, but what if they just close their browser without logging out?
author & internet detective
As for the cleanup, you can create a session listener to detect when a session invalidates itself. this will trigger on explicit logout and session timeout.
Joined: Feb 15, 2005
If you were using Struts 2, you would not be using a <logic:iterate> tag. You must be using some version of Struts 1. The latest version of Struts 1 (1.3.10) does allow an action attribute for the html:img tag. However, if you're using a version that doesn't allow it, just use page="myImageAction.do".
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com