This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design 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
 
Have you checked out Aspose?
 
subject: Thread Safe Objects
 
It's not a secret anymore!