tomcat-users mailing list archives

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

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:p2p@garethwestern.com]
>Sent: Wednesday, April 07, 2004 6:48 PM
>To: tomcat-user@jakarta.apache.org
>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: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message