• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

isThreadSafe Doubt

 
Ranch Hand
Posts: 124
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can we create a thread safe JSP ?

A <%@ page isThreadSafe = "true" %>
B <%@ page implements="SingleThreadModel" %>
C <%@ page isThreadSafe="false" %>
D <%@ page extends="SingleThreadModel" %>

Asnswer = c...
please explain why not a...thank you..
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The correct answer is a only.

a tells that my servlet is thread safe and dont want to implement SingleThreadModel.

If you want to implement SingleThreadModel , go for
isThreadSafe="false" which will degrade the performance.
 
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@ page isThreadSafe="true" %>
This implies that the JSP page author would take the full responsibility of making the JSP thread safe, which means the author would have necessary synchronized blocks. The container will not provide any help [help = make jsp implement SingleThreadModel marker interface].

When i write <%@ page isThreadSafe="false" %> means i don't know how to make the JSP thread safe and i leave everything to the container. Now when container translates the JSP to servlet, it makes the servlet to implement the SingleThreadModel with this every client request will have their own instances of the servlet hence making the JSP thread safe.

Hope this clears.
 
Surajsingh Thakur
Ranch Hand
Posts: 124
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all...

 
Author
Posts: 3445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The Servlet 2.4 specification 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.

- Sun Forums
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Praveen Kumar:
a tells that my servlet is thread safe and dont want to implement SingleThreadModel.




Not really. In fact you are the responsible to make thread safe JSP.

<%@page isThreadSafe="true" %> means jsp allows concurrent access(multiple thread)

Hope this helps
 
The happiness of your life depends upon the quality of your thoughts -Marcus Aurelius ... think about this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic