• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about isThreadSafe

 
Timber Lee
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following statements are true for
Which of these are true. Select the two correct answers.
1The default value of isThreadSafe attribute of page directive is true.
2If isThreadSafe attribute of page directive is set to true, then JSP container dispatches request for the page sequentially.
3When isThreadSafe attribute of page directive is set to true, a thread is created for each request for the page.
4Setting isThreadSage attribute to true for JSP pages, can lead to poor performance.
why is ans.3 true?
 
Peter Venema
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I answer by head, too lazy to check it in the book.
If isThreadSafe is true, the SingleThreadModel will be implemented in the JSP servlet. This means that only one thread at a time can approach methods.
If more threads want to approach the servlet, more instances will be created.
Hope it helps,
Peter
 
yi zhu
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When isThreadSafe attribute of page directive is set to true, which is also the default setting, the servlet generated by this jsp does not implement the interface SingleThreadModel. So Answer 3 is correct.
 
k space
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Peter Venema:
If isThreadSafe is true, the SingleThreadModel will be implemented in the JSP servlet.

Setting isThreadSafe="true" informs web container that I am thread-safe, while implementing SingleThreadModel tells the container that I am NOT thread-safe.
Back to the option 3, I think thread is always created by the container (not the result of isThreadSafe="true|false").
 
Maha Annadurai
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Option 1 is definitly right
Options 2 and 4 are definitly wrong
Option 3 is correct on its own eventhough it could have been worded better to insist the point 'mulitiple requests can be served concurrently'.
Since the question asks to pick 2 right answers, the best bet would be Options 1 and 3 I guess.
Regards,
Maha Anna
[ December 02, 2002: Message edited by: Maha Annadurai ]
 
Debashish Chakrabarty
Ranch Hand
Posts: 231
Firefox Browser Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Peter Venema:
If isThreadSafe is true, the SingleThreadModel will be implemented in the JSP servlet.

I thinks the above is the exact opposite. Infact, when isThreadSafe=false, container gets an indication to implement the SingleThreadModel. Am I wrong?
[ December 12, 2002: Message edited by: Debashish Chakrabarty ]
 
Vidya Nayak
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, I just checked Manning Book...
By default, the value of isThreadSafe attribute is true. This tells the container that it can dispatch requests to the page's servlet concurrently in different threads.
If isThreadSafe is set to false, the container dispatches the requests to the page one at a time in the order they are received.
Cheers,
Vidya
 
Kai Liu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I have a question about the manning book.
in page 196 what is the difference of isThreadSafe's value between true and false.
Parts of the code is listed as follow :
------------------------------------------
<%@ page isThreadSafe="ture" %>
<%! int j=0; %>
<%
int i;
for (i=0; i<1000; i++)
{
out.print("The value of j is " + j + "<br>");
j++;
}
%>
------------------------------------------
I can't see any difference between these two settings.
Can someone tell me ?!
Or what the behaviors differ ?!
Thanks in advance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic