wood burning stoves 2.0
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Neil: Specification and Struts" Watch "Neil: Specification and Struts" New topic

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..
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.
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
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>
I agree. Here's the link: http://aspose.com/file-tools
subject: Neil: Specification and Struts
jQuery in Action, 3rd edition