File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes isThreadSafe Doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "isThreadSafe Doubt" Watch "isThreadSafe Doubt" New topic
Author

isThreadSafe Doubt

Surajsingh Thakur
Ranch Hand

Joined: Sep 09, 2008
Posts: 124

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..


BE (Computer Science) SCJP 4 (80%) SCWCD 5 (97%) IBM CAD(98%) IBM CAppD(100%) IBM SD(100%)
Praveen Kumar
Ranch Hand

Joined: Nov 06, 2006
Posts: 133
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.
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
<%@ 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.


SCJP, SCWCD, SCBCD
Surajsingh Thakur
Ranch Hand

Joined: Sep 09, 2008
Posts: 124

Thank you all...

arulk pillai
Author
Ranch Hand

Joined: May 31, 2007
Posts: 3219
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


Java Interview Questions and Answers Blog | Amazon.com profile | Java Interview Books
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: isThreadSafe Doubt
 
Similar Threads
Doubt abt Page directive
about isThreadSafe attribute of page directive ...
Single Thread Model
Thread Safe Servlet
What to do to make this web page thread safe?