aspose file tools*
The moose likes JSP and the fly likes Thread Safe Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Thread Safe Objects" Watch "Thread Safe Objects" New topic
Author

Thread Safe Objects

Rajeev Iyer
Ranch Hand

Joined: Jun 19, 2002
Posts: 42
Which are the thread safe objects in JSPs ?
Can a class variable (a static variable ) be thread safe?
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
In general, only "method" variables (declared in <% %> are definitively thread safe in JSPs.
Class ("static") variables are not. Object (instance) variables are not. Variables stored in application and session contexts are not. Variables stored in request or page contexts are probably thread safe, unless they are also one of the unsafe categories above.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Mani Narain
Greenhorn

Joined: Dec 14, 2003
Posts: 4
To add...I guess the instance variables are thread safe if the JSP page has the directive (<%@ page isThreadSafe=false)..it is like JSP page implementing the SingleThreadModel...people correct me if I am wrong..
sankar
Greenhorn

Joined: Jan 28, 2003
Posts: 4
Mani i hope you are correct .and in case of Single Threaded model static variables are not thread safe.
Patricia Johannes
Greenhorn

Joined: Nov 08, 2003
Posts: 2
but singlethreaded model is defered in Servlet 2.4
 
Consider Paul's rocket mass heater.
 
subject: Thread Safe Objects