Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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
 
Do you pee on your compost? Does this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic