Maxim Senin PMI wrote:
>
>
> It's always a servlet behind JSP. For ThreadSafe=false, i.e. when JSP
> implements
> STM interface, server has to know whether the service() method of
> servlet is
> currently running. If all instances of servlet are currently "busy"
> execuing
> their service() method, the server probably will try to create another
> instance
> of JSP and pass control to it. If server has limitation on number of
> servlet
> instances, it will probably wait for an instance to become available.
>
> The problem is that according to servlets API execution of service()
> method is
> transparent to the server. So unless there's some weird hack in the
> servlet's
> code, HOW DOES THE SERVER KNOW about the STATUS of execution of
> servlet's
> service() method (whether it's busy or not)?
>
The best way to answer questions like this is to look at the source code
for an open source servlet engine. Here's the approach taken by two
popular ones:
* Apache JServ maintains a pool of instances for an STM
servlet. When you request that servlet, it allocates an
instance, calls the servlet, and then returns the instance.
This all works very similarly to a database connection pool.
* Tomcat does not maintain a pool of instances. Instead, if
the servlet in question implements STM it calls the servlet's
service() method inside a "synchronized" block on that
instance -- thus using Java's object synchronization primitives
to enforce the rule about only one thread executing inside the
service() method at a time.
Craig McClanahan
===========================================================================
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