This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Background of this question concerns a web app built using the Model 2 framework of the MVC architecture... Can I assume that any JavaBean that I instantiate for purposes of view in JSP, by custom tags or <jsp:usebean.../>, are inherently thread-safe, as long as they're declared and instantiated within methods of the servlet instance? From what I know on servlets and thread safety I want to say 'yes', but some feedback to the contrary (if any) would help. Thanks! --- [ April 19, 2002: Message edited by: Toby Davis ]
Okay. So even though the bean was instantiated within an implemented Action's method (within the servlet-controller's instance), and not as a class member, it's still open to multi-threading issues dependent on which scope I place it in. I can understand, logically, why an Application scope would be open to multiple threads... it's being shared by all threads... but is this inherently assumed? Something that says request objects are thread-safe inherently as part of the JSP or servlet spec... or a request can be altered by another thread before my app processes it? I could not find much info about threading issues in the 2.3/1.2 specs. Threading issues are giving me a headache! I just want to be sure I have no thread-issues with my web app - and I'm using request and session mostly, with beans that were declared and instantiated within servlet methods. ---
Joined: Apr 09, 2002
I found a forum thread that talks a bit about request objects needing sychronization to be thread safe. So this leads me to believe that request is not thread-safe inherently. I'm using custom tags instead of usebean in JSP, where the bean is placed in page scope, and finding the javabean instance by doing a pageContext.findAttribute() on custom tag call. Which means that, do I need to sychronize the instantiation and population of the JavaBean when placing it into a request scope? --- [ April 20, 2002: Message edited by: Toby Davis ]