wood burning stoves 2.0*
The moose likes Servlets and the fly likes Prevent multiple upload in browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Prevent multiple upload in browser" Watch "Prevent multiple upload in browser" New topic
Author

Prevent multiple upload in browser

chennai Kumar
Ranch Hand

Joined: Jun 04, 2005
Posts: 66
Hai All,

User upload a single .xls file from browser and we are reading the data using POI library and saving in to the database.
Here my scenario is we have to prevent the user for mutiple upload until one compete cycle is finish. When user tries to upload we show the message as
"Already one excel file is in processing,Please upload after job is finish".

I like to use synchronize method, but i have a doubt as how to trace one cycle is completed or not.

Here one cycle means that reads the data from the excel file and saving in to the database.

Thanks,
Ram kumar
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

As you are using Asynchronous i guess its AJAX only , so until the request has been recivied that is readystate is 4 and status is 200 keep the Mouse in Busy state (that is a dumble symbol) and after that keep mouse style in normal state .


Save India From Corruption - Anna Hazare.
chennai Kumar
Ranch Hand

Joined: Jun 04, 2005
Posts: 66
Hai,

I am not using AJAX, simple javascript method it calls the action class.From the action class we are doing the business that reads the excel file and saves in to
the database. I created synchronized method in java to prevent, but here I have a doubt as how we know one complete cycle is finished or not.
Because When the user tries to upload another excel file from browser before the complete cycle we show the message to user as "Already one excel file is in
processing, Please upload after job is finish" in screen.

Please share best approch.

Thanks,
chennai Kumar
Ranch Hand

Joined: Jun 04, 2005
Posts: 66
Hai All,

Please share your views.

Thanks
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Use an in-memory lock against the session id.
Put a synchronized set in the application context, set the id in the set. In the upload code, remove the id in a try/finally block.
chennai Kumar
Ranch Hand

Joined: Jun 04, 2005
Posts: 66
Hai,

Could you please share a example

Thanks and Regards,
Ram kumar
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

My explanation was fairly detailed, is there a specific part you need help with?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Prevent multiple upload in browser
 
Similar Threads
No one is there to solve excel problem????
Flat file to database?
Accesing Excel data sheets through JDBC
What is the best way to store List<List<String>> in database?
JSP-EXCEL save defualt in .xls extension, open excel with in the browser