wood burning stoves 2.0*
The moose likes Servlets and the fly likes Is my servlet threadsafe? 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 » Java » Servlets
Bookmark "Is my servlet threadsafe?" Watch "Is my servlet threadsafe?" New topic
Author

Is my servlet threadsafe?

ATURINA AAurelien
Greenhorn

Joined: Mar 15, 2004
Posts: 2
Hello,
I'm trying to build a very simple MVC framework. I work with a single frontservlet, that dispatches the queries to handler objects. The handler are simple java beans, and the front servlet invoke them with the help of java.lanf.reflect. My problem follows:
I would like to know if it is possible to use the HttpServletRequest, or the HttpServletResponse, or the ServletContext, as object attributes for the handler?
I know that if my handler were servlets, I wouldn't be allowed to do that, because it's not threadSafe. But my handler are simple java bean that are invocated by the frontservlet with the reflect package.
Is my servlet threadsafe?
Any help would be nice.
Thank you, regards,

Aurelien
Tod Checker
Greenhorn

Joined: Feb 19, 2004
Posts: 27
Its thread safe if the methods that use httpservletresponse, httpservletrequest, and servletcontext are declared and instaniated within a service method of the servlet. Anything outside the service methods are not thread safe.
ATURINA AAurelien
Greenhorn

Joined: Mar 15, 2004
Posts: 2
Thanks for your answer.
As my handler objects (who have the HttpServletRequest,HttpServletResponse,ServletCOntext) are dynamically (with java.lang.reflect) invokated in the service method and are never used outside service method, I know now that my FrontServlet is ThreadSafe.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is my servlet threadsafe?
 
Similar Threads
REFRESH PROBLEM
Urgent !!! Scalabilty of Front Servlet
Instance variables in Servlet
synchronization of the connection object
Changing the url in browser