This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSP and the fly likes how can we make JSP single threaded? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "how can we make JSP single threaded?" Watch "how can we make JSP single threaded?" New topic

how can we make JSP single threaded?

Priya Mandal

Joined: Oct 04, 2012
Posts: 2
Would like to know how can we make JSP single threaded?
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 923

can you please elaborate what do you mean MAKE JSP SINGLE THREADED ?

OCPJP 6(100 %) OCEWCD 6(91 %) OCPJBCD(93%)
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 39547
A much better question would be: how can I make my JSP/servlet/Web app multithread safe? Web apps are inherently multi-threaded, and you should learn to write code that is, too.

Ping & DNS - updated with new look and Ping home screen widget
Stefan Evans

Joined: Jul 06, 2005
Posts: 1016

You CAN make a JSP singlethreaded like this:

However there are a huge number of reasons why you should NOT go down this path.

I think the best answer to this is to refer to the spec description of this property:
isThreadSafe Note: The Servlet 2.4 speciļ¬cation deprecates SingleThreadModel, which is the most common mechanism for JSP containers to implement isThreadSafe.
Page authors are advised against using isThreadSafe, as the generated Servlet may contain deprecated code.

Indicates the level of thread safety implemented in the page. If false then the JSP container shall dispatch multiple outstanding client requests, one at a time, in the order they were received, to the page implementation for processing.
If true then the JSP container may choose to dispatch multiple outstanding client requests to the page simultaneously.
Page authors using true must ensure that they properly synchronize access to the shared state of the page. Default is true.

Note that even if the isThreadSafe attribute is false the JSP page author must ensure that accesses to any shared objects are properly synchronized., The objects may be shared in either the ServletContext or the HttpSession.

I agree. Here's the link:
subject: how can we make JSP single threaded?
Similar Threads
JSP - single threaded
single thread
Singleton servlet
Jsp question