I think you are under a slight misunderstanding. By default, the
"isThreadSafe" page directive is true. This means that the JSP code is
(supposed to be) thread-safe, and therefore the generated servlet does NOT
implement SingleThreadModel. The "isThreadSafe" directive equal to true is
not a guarantee by the system that your JSP will be implemented in a
thread-safe manner, rather it's the opposite; it's an assertion by you, the
JSP author, that there's nothing in your code that is not thread-safe
(thereby allowing the system to run that JSP in a multi-threaded manner). If
you do something in your JSP that is known to be not thread-safe, such as
using the <%! %> tag to declare a variable that you don't want concurrent
access to, then you need to set "isThreadSafe" to false. It is then that the
generated servlet will implement SingleThreadModel.

The "useBean" tag with no scope attribute gives you a method-local object,
which is thread-safe. Objects stored in the session scope are technically
not thread-safe in that there's no automatic mechanism that prevents them
from being accessed concurrently. In practice, however, if you assume that
the session mechansim is working correctly in your server, there should be
only one thread at a time for a particular session. Unless, of course, your
user decides to open another browser window to your application, and manages
to hit the "submit" button of the second window before the request from the
first window has finished. But this is a pretty low probability event.

--Jim Preston

-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Panagiotis Konstantinidis
Sent: Friday, August 04, 2000 12:56 AM
To: [EMAIL PROTECTED]
Subject: JSP thread-safe


     By default servlets generated from JSP pages are thread-safe. I guess
that this means that the servlets generated implement the SingleThreadModel.

    My question is if requests to the same page will be serialized thus
decreasing site performance. And what if I don't compile JSP pages with
thread-safe enabled? For example as far as I know beans and variables
declared in JSP pages are within the scope of jsp_service method thus making
them local variables not affected by a call from another thread. So why not
use not thread-safe pages? Are beans in session scope affected?

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to