File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is my servlet threadsafe?

 
ATURINA AAurelien
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic