Hans Bergsten wrote:
> What's needed then is ServletContext.getName() method that returns the
> registered name.
Agreed. But I believe that having to use getName() and setAttribute()
to write a simple counter servlet is overkill.
This is why I believe in the idea of having an interface (or something)
which a servlet uses to indicate it's capable of having multiple
instances created across back-end servers. Without that tag, the
servlet can follow the easy lifecycle. With that tag, it obeys the
more complicated logic that shared state has to go in the context,
and that state shared per name has to have its variable name mangled.
The distinction is especially useful when a servlet is mostly state
(such as a counter) and where creating multiple instances across back
end servers is a performance penalty because the server has to expend so
much work keeping the state in sync. You'd do better performance wise
and code-readability wise to leave one instance on one machine.
This also will improve portability. A special "distributable"
interface can ensure that only servlets blessed for distribution are
expected to perform correctly.
-jh-
--
Jason Hunter
[EMAIL PROTECTED]
Book: http://www.servlets.com/book
Article: http://www.javaworld.com/jw-12-1998/jw-12-servletapi.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