Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript Java struts
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 8-Dec-12 17:47pm
Comments
Gian rebollido at 26-Mar-13 1:37am
   
i don't think so.. post your code first..

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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,
  Permalink  

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

  Print Answers RSS
0 Mathew Soji 274
1 BillWoodruff 270
2 Afzaal Ahmad Zeeshan 244
3 Sergey Alexandrovich Kryukov 240
4 Raul Iloc 160
0 OriginalGriff 6,219
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,103
3 Manas Bhardwaj 4,549
4 Maciej Los 3,845


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 24 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100