QM wrote:

On Wed, Apr 07, 2004 at 11:47:50PM +0100, Gareth Western wrote:
: 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.


Silly question 1:
        is "myObj" null in the servlet that calls setAttribute()?
        (have to ask)

Silly question 2:
single Tomcat install, or clustered? i.e. are getAttribute()
and setAttribute() being called from the same host, same
webapp?


Thanks for the replies :)

Answer 1: In the servlet that SETS the attribute, myObj is not null.
Answer 2: This is a single tomcat install

And in reply to Nikola (quoting her response first):

>>If you wish to share things, runtime, you should use one of defined contexts:
>> page context
>> request context
>> session context
>> application context
>>If servlets are in the same request chain, you can use request context. If they are in the same session instance, you can use session context. Or you can use >>application context.


The servlets are in neither the same request nor session instance, so i'm trying to use application context. However, according to http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/context.html I need to set the crossContext value of the Context element for the webapp from which I wish to call ServletContext.getContext() to TRUE. However I'm not sure how/where to do this. I tried adding the following line to the applications WEB-INF/web.xml yet I'm still getting a null value returned:
<web-app>
...
<Context crossContext="true"/>
</web-app>


=\

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to