wood burning stoves*
The moose likes Struts and the fly likes Neil: Specification and Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Neil: Specification and Struts" Watch "Neil: Specification and Struts" New topic
Author

Neil: Specification and Struts

Pravin Panicker
Ranch Hand

Joined: Oct 05, 2000
Posts: 62
Hello Neil,
Sun's servlet specifications states that it is best avoided to pass the request, response
to another thread of execution.. as they are not gauranteed to be thread safe.
to quote..
"
2.3.3.3
A Developer should note that implementations of the request and response objects are not
guaranteed to be thread safe. This means that they should only be used in the scope of the
request handling thread. References to the request and response objects should not be given
to objects executing in other threads as the behavior may be nondeterministic.
"
Is the Action Servlets behaviour to pass the request, response to the Action class any cause of concern.
Please shed more light on this in the context of the specification


Pravin R Panicker<br />SCJP,SCWCD
Anupreet Arora
Ranch Hand

Joined: Jun 17, 2003
Posts: 81
Interesting question..
But I think that though an ActionServlet passes the request and reponse objects to an Action class, it does not start a new or a separate thread for it. The ActionServlet itself might be executing in a separate thread for a fresh request, as is true with all servlets, but it does not spawn any new threads when it delegates to the Action classes.
Rgds,
Anupreet Arora
Pravin Panicker
Ranch Hand

Joined: Oct 05, 2000
Posts: 62
okk Thanks.. I guess the behaviour of Action Servlet's service would be

void service(){
1. Load the action class from config
2. Pass the parameters and call its action method
}

So it all happens in the same thread There is a containment relationship between the Action Servlet and the Actionclass
guess i was plain confused.. Thanks a lot
Neal Ford
Author
Ranch Hand

Joined: Oct 23, 2003
Posts: 82
Yes, this is correct -- the Action is invoked in the thread spawned for the user from the ActionServlet.


Neal Ford<br />Author, <i>Art of Java Web Development: Struts, Tapestry, Commons, Velocity, JUnit, Axis, Cocoon, InternetBeans, WebWork</i><br /><a href="http://www.nealford.com" target="_blank" rel="nofollow">www.nealford.com</a>
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Neil: Specification and Struts
 
Similar Threads
Thread safe Please help!!!
Thread Safe
HttpSession methods thread-safe?
ThreadSafety of HttpServletRequest & HttpServletResponse objects
Request Attributes Thread Safe?