| 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.
|
 |
 |
|
|
subject: display images in preview form.
|
|
|