This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes display images in preview form. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "display images in preview form." Watch "display images in preview form." New topic
Author

display images in preview form.

azhar bharat
Ranch Hand

Joined: Jul 17, 2006
Posts: 87
I have a form in my struts application which when submitted goes to a preview page. All the fields in the form are displayed in preview page. And the data is written only after confirm button in pressed in preview form.

Now, the problem:
In the form there are file fields for uploading image.
I want to display these images in the preview form.
As I said I want the data to be written to db only after response in preview page.
How do I go about it???
Can I do it without introducing another bean?(the form bean is already in session)
I am also concerned about the size of the form bean in session when images are included. Should i change my approach???
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
One possibility would be to write the images immediately as a BLOB to the database in a temporary table, and then move it to the permanent table after the confirmation panel. That way you don't have to keep the images in the session. Images can be quite large, and putting that much data in an HttpSession is not recommended.
[ August 05, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
azhar bharat
Ranch Hand

Joined: Jul 17, 2006
Posts: 87
Hi Merill
I too considered keeping it in a temporary table.
One problem with this approach, though not very serious one, is that the images remain in db for sessions which expires prematurely due to causes like session timeout. In time these images will take a lot of space.
How can I clear these images when session expires?
[ August 05, 2006: Message edited by: azhar bharat ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you are using a container that implments servlet 2.3 or above, you can write an application event listener to handle this.

Here is a link that explains a bit about how to write them. Basically, you can register an event listener that will fire any time a session is about to expire. In this class you could then clean up whatever temporary data was created during that session.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: display images in preview form.
 
Similar Threads
Spring portlet MVC forms, multipart data and servlets?
Preview Page before Submission
Internet Explorer and Session Beans
URGENT Help Needed ...!!
How to update Session variable with Form Data ?