Hi,
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
objects.

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 [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, April 07, 2004 6:48 PM
>To: [EMAIL PROTECTED]
>Subject: Inter Servlet Communication
>
>Hi,
>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
using
>getServletContext().setAttribute("some.name", myObj) however I was
unable
>to retrieve the object in the other servlet.
>
>I notice there are some 'public' ServletContext attributes such as
>
>org.apache.catalina.jsp_classpath
>javax.servlet.context.tempdir
>org.apache.catalina.resources
>org.apache.catalina.WELCOME_FILES
>
>So where/how does Tomcat define these?
>
>Even just general help on dealing with context is appreciated. Many
thanks
>for any and all help,
>
>~Gareth
>
>PS Running Tomcat 5.0.18. If any other particulars would help then let
me
>know. Thanks!
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to