Jason Hunter wrote:
>
> Craig R. McClanahan wrote:
> > As David points out, though, ServletContext.setAttribute() is
> > designed for sharing global data for the same servlet, or for
> > different servlets.  The servlet context also serves as the
> > "Application" scope in JSP, for the same reason.
>
> One thing I miss with ServletContext.setAttribute() however is the
> ability to easily have different data kept per registered servlet
> name.  For example, with JWS if you have a counter servlet
> registered as "counter" and registered also as "howmany" you will
> have two instances created, one per name.  Maintaining a separate
> count for /servlet/counter and /servlet/howmany is trivial -- just
> use instance variables to keep the count.
>
> To do this using setAttribute() is far harder.  You have to come up
> with a way to encode your registered name in the context variable
> name to keep the values different.  And coming up with your
> registered name isn't always possible.  You can try getRequestURI()
> but that will fail with prefix- or suffix-mapped servlets.

What's needed then is ServletContext.getName() method that returns the
registered name.

--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

___________________________________________________________________________
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

Reply via email to