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 SingleThreadModel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "SingleThreadModel" Watch "SingleThreadModel" New topic
Author

SingleThreadModel

Chris Salivar
Ranch Hand

Joined: May 25, 2001
Posts: 34

If a servlet implements the SingleThreadModel interface then will the instance variable of the servlet be thread-safe?
TIA
- Chris
Phil Hanna
Ranch Hand

Joined: Apr 05, 2001
Posts: 118
Yes, but it's almost always a poor design to do this. Why do you need instance variables to be persistent? An HTTP session is a much cleaner way to do this. SingleThreadModel does not scale well.
------------------
Phil Hanna
Sun Certified Programmer for the Java 2 Platform
Author of :
JSP: The Complete Reference
Instant Java Servlets


Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
Yes. That's what implementing the model entails.
I am leaving out (since you didn't ask) the details of how a Servlet engine would implement http://java.sun.com/j2ee/j2sdkee/techdocs/api/javax/servlet/SingleThreadModel.html such model.
An I agree w/Phil, BTW.


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
 
 
subject: SingleThreadModel