This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff 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 OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Thread Safe Objects" Watch "Thread Safe Objects" New topic

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

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 ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Mani Narain

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) is like JSP page implementing the SingleThreadModel...people correct me if I am wrong..

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

Joined: Nov 08, 2003
Posts: 2
but singlethreaded model is defered in Servlet 2.4
Don't get me started about those stupid light bulbs.
subject: Thread Safe Objects