Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a file upload solution in Struts2/spring integrated app.
I have a validation for the files the user selects. if the user selected 3 files and 1 of them fails validation, i return the user back to the same upload page.

My problem is, for the other two files that went through the file validation I cannot keep the content(file path) on postback (when i return to the upload page with error)due to security reasons for browsers.

Right now I am storing them in the session. But jvm might crash with this.
Is there a better way to implement this ??
Posted
Comments
Gian rebollido 26-Mar-13 1:37am    
i don't think so.. post your code first..

1 solution

Hello,

You should do such task in background as a asynchronous batch job. One simple way is to use Quartz Scheduler and use to validate the file contents. This way user does not have to wait for the validation to complete. The scheduled job will typically use the database to keep track of progress. You can build a view over this table so that users can find out what happened to their uploads.
However if you must do this in a synchronous manner, then there is no need to keep the file contents of successfully validated files anywhere. Just keep the names in a session variable. On postback use values from session to skip validations of already checked files. For safety reasons you may also want to compute the checksums and store them as well. This way if new and old checksums do not match then you can re-validate the files. Once the validation is successful you can remove this variable from session.

Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900