wood burning stoves*
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "File Access from Servlets - Concurrency" Watch "File Access from Servlets - Concurrency" New topic

File Access from Servlets - Concurrency

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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.

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.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Yeah, I agree. Make sure you synchronize.
I agree. Here's the link: http://aspose.com/file-tools
subject: File Access from Servlets - Concurrency
Similar Threads
regarding constructor in servlet
How does the Log file function in a multitude of environments?
File access from servlets - Concurrency(Urgent)
[S2] Multiple files sent simulatneously with out.write() results in corrupted data streams
Can we deploy multiple application on JBoss at the same time?