File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes isThreadSafe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "isThreadSafe" Watch "isThreadSafe" New topic
Author

isThreadSafe

scottie zman
Ranch Hand

Joined: Aug 08, 2001
Posts: 40
Hi,
I'm thinking about ways to architect a XML BBS with JSP.
In the BBS there is an XML file, userPosts.xml, that contains lots of user information - username, number of posts, last login, etc - and is accessed by all the XML thread files - one XML file for each topic. Whenever a person adds a message, it first updates/creates the thread XML file and then updates userPost.xml with that user's info.
I'm new to JSP - this system is actually in ASP - and I'm wondering what would be the best way to ensure that the userPosts.xml file was only getting opened and re-written by one user at a time?
I see that there is the isThreadSafe page directive - can I just have a page that works with userPosts.xml and set isThreadSafe = false? Will that ensure correct marshalling of the processes lined up for the rewriting of this file? Or is there a better, faster way?
thanks for any ideas,
Scottie Zman
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

Well, clever as my designs may be, I must admit that the FIRST thing I'd do when changing platforms would be to see if someone hadn't already written one of those that I could steal or adapt (I'd suggest the JavaRanch one, but it's not in Java!).
Second suggestion would be to consider forgoing XML and using a DBMS. XML is essentially a sequential medium, not a random-access or skip-sequential one. and I wouldn't recommend it for high-volume use. J2EE has most of its concurrency services written for DBMS'type stuff (there ARE XML-specific DBMS's though).
You can use isThreadSafe(), but it constricts the entire process. Much depends on the load.


Customer surveys are for companies who didn't pay proper attention to begin with.
scottie zman
Ranch Hand

Joined: Aug 08, 2001
Posts: 40
>> You can use isThreadSafe(), but it constricts the entire process
The entire process being.... just that page and all the visitors who are accessing it, or the entire server?? Does it just line up the requests in a jfirst come first serve manner, or do requests ever get dropped?
If it's just the page, then I can probably live with that.
Scottie Zman
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

Just that page.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: isThreadSafe
 
Similar Threads
isThreadSafe="false"
isThreadSafe
Is JSP thread safe?
Thread safety of JSP:useBean scope=application
JSP - single threaded