tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: Inter Servlet Communication
Date Thu, 08 Apr 2004 12:52:13 GMT

You should be able to use the ServletContext as you're trying to do.
Two servlets in the same webapp will share the context, and
setAttribute/getAttribute is a decent way to go about sharing your

Can you write a simple logging ServletContextAttributeListener and see
if it shows the expected behavior?

Tomcat uses the same mechanism as you (the setAttribute method on the
ServletContext implementation) to set the Servlet Specification-mandated
attributes, like javax.servlet.context.tempdir.  There's no magic ;)

BTW, all ServletContext attributes are "public."

Yoav Shapira
Millennium Research Informatics

>-----Original Message-----
>From: Gareth Western []
>Sent: Wednesday, April 07, 2004 6:48 PM
>Subject: Inter Servlet Communication
>Can someone fill me in as to what I need to do to make objects that are
>instanstiated in one servlet available to another servlet? I tried
>getServletContext().setAttribute("", myObj) however I was
>to retrieve the object in the other servlet.
>I notice there are some 'public' ServletContext attributes such as
>So where/how does Tomcat define these?
>Even just general help on dealing with context is appreciated. Many
>for any and all help,
>PS Running Tomcat 5.0.18. If any other particulars would help then let
>know. Thanks!
>To unsubscribe, e-mail:
>For additional commands, e-mail:

This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message