aspose file tools*
The moose likes Servlets and the fly likes File Access from Servlets - Concurrency Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "File Access from Servlets - Concurrency" Watch "File Access from Servlets - Concurrency" New topic
Author

File Access from Servlets - Concurrency

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi.
I need to access a file for read/write from two different servlets. How can i ensure concurrency ?i.e I dont want the file to be accessed by one servlet while it is being written into by another.
Thanks in advance.
henley
Greenhorn

Joined: Jul 06, 2000
Posts: 16
A quick suggestion would be to pull out the code that creates or obtains the handle to the file and put it in a separate class as a static method. This way, each servlet can use this code and it can be synchronized to ensure concurrency.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Yeah, I agree. Make sure you synchronize.
jashman
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File Access from Servlets - Concurrency