Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What about the following Q. in SCWCDWhiz?

 
Nazmul Huda Sarkar
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about the following Q. in SCWCDWhiz?

Q. Which of the following JSP directives can be used to make the service() method implementation of a JSP threadsafe?

a. <%@ page isThreadSafe="false" %>
b. <%@ page isThreadSafe="true" %>
c. <%@ page isSingleThread = "true" %>
d. <%@ page isSingleThread = "false" %>
I think b. is correct. But they said a. is correct and their explanation is as follows:
"A is the correct choice. By default, the service() method of the JSP page implementation class that services the client request is multithreaded. Thus, it is the responsibility of the JSP page author to ensure that access to shared state is effectively synchronized. There are a couple of different ways to ensure that the service methods are thread-safe. The easy approach is to include the JSP page directive:
<%@ page isThreadSafe="false" %>
This causes the JSP page implementation class to implement the SingleThreadModel interface, resulting in the synchronization of the service method, and having multiple instances of the servlet to be loaded in memory. "
Please someonr make me clear...
[ August 09, 2002: Message edited by: Nazmul Huda Sarkar ]
 
Dave Thomas
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. Both the explanation and answer are right. Declaring "isThreadSafe = false" means that the developer has not taken any action to make it threadsafe and so SingleThreadModel is implemented
 
Leon Zhou
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, "set it to True" is to tell the container that "OK, I have make sure that this jsp page is thread-safe, you can call multiple threads on this instance".
 
Nazmul Huda Sarkar
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm...that mean I was wrong
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic