aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Single Threaded Model Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Single Threaded Model Question" Watch "Single Threaded Model Question" New topic
Author

Single Threaded Model Question

riya s
Ranch Hand

Joined: Feb 28, 2003
Posts: 110
The specification guarantees that the servlet implements the SingleThreadModel the container will not execute the service method with more than one thread.
When we implement this model we assume that when we define the instance variables they are thread safe (just like the local variables)
Question is: Why the above? In JSP when we define instance variables using declaration, they are not part of the service method. So instance variables are not part of service and the model guarantees the container will not execute the service method with more than one thread...
Any idea?
Sean Joung
Greenhorn

Joined: Jan 20, 2004
Posts: 4
FYI SingleThreadModel is out of Servlet2.4
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
Originally posted by Priya Shah:

When we implement this model we assume that when we define the instance variables they are thread safe (just like the local variables)
Any idea?

We donot assume that the instance variables are thread safe, but they are in fact as the container provides every request with a separate servlet instance.
Originally posted by Priya Shah:

Question is: Why the above? In JSP when we define instance variables using declaration, they are not part of the service method. So instance variables are not part of service and the model guarantees the container will not execute the service method with more than one thread...
Any idea?

I think service method has no knowledge of the instance variables in your servlet class (or the jsp that ultimately turns into a servlet). When it comes to servlets, we derice from the HttpServlet and override the doGet and doPost methods. The service method just routes the appropriate HTTP requests to the methods in the object. I'm a little confused with you mixing the instance variables with the service method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Single Threaded Model Question