Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can we make JSP single threaded?

 
Priya Mandal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would like to know how can we make JSP single threaded?
 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please elaborate what do you mean MAKE JSP SINGLE THREADED ?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stefan Evans
Bartender
Posts: 1774
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.





 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic