As far as I know, there is nothing that requires a server to only use one
instance of a servlet. In fact any servlet that implements the
SingleThreadModel will most likely be run by separate instances. I'd be
careful trying "tricky" things if you want to maintain the portability of
your code.
(*Chris*)
----- Original Message -----
From: hhito <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, August 14, 1999 9:52 AM
Subject: Static and non-static methods in servlets
> It seems to me that it doesn't matter much if a method of a servlet is
> static or non-static. The servlet engine will use the same instance of
> the class to handle all requests anyway. Am I wrong?
>
> I know there are some subtle situations where you might have more than
> one instance running because of dymaic reloading. And of course static
> methods can't use non-static data. But since I don't keep any
> non-static data in my servlets these are not problems. I often use
> static methods like this (simplified code):
>
> public class MyServlet {
>
> public void doGet(req, res) {
> result = performService(req, res);
> out.println(result);
> }
>
> public static performService(req, res) {
> // whatever
> }
> }
>
> This gives other servlets access to the same services simply by calling
> MyServlet.performService(). This saves me from messing with
> getServlet(). Are there any syncronization issues invloved here or any
> other problems I'm not aware of?
>
>
> Thomas Oldervoll
> System developer, University of Bergen
>
>
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html