You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Gabriel Mihalache <ga...@fx.ro> on 2002/06/18 23:52:30 UTC
one context per server
is there a way to share a single JNDI context for all webapps?
can this context be accesible thru getServletContext() ?!
=====================================
Oh, no! Not me! I never lost control /
You're face to face /
With the man who sold the world - David Bowie
Re: is there only static objects in Tomcat?
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 18 Jun 2002, Ray Letts wrote:
> Date: Tue, 18 Jun 2002 15:00:23 -0700
> From: Ray Letts <rl...@etc.bc.ca>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>,
> rletts@etc.bc.ca
> To: Tomcat Users List <to...@jakarta.apache.org>
> Subject: is there only static objects in Tomcat?
>
>
> I read a previous thread where someone stated that: "you know that
> Tomcat creates all objects as static?"
>
There is no such thing as "creating an object as static". You might be
confusing this with creating a single instance of a servlet, which is
shared across all requests to that servlet.
Fundamentally, this means you cannot use static or instance variables in
our servlet class to maintain per-request state information. Use local
variables in our methods, or pass things around as request attributes, in
order to deal with this.
Craig
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
is there only static objects in Tomcat?
Posted by Ray Letts <rl...@etc.bc.ca>.
I read a previous thread where someone stated that: "you know that
Tomcat creates all objects as static?"
So then, if user A contacts a servlet via Tomcat that creates a person
object and stuffs some personal info in it
and user B later contacts the same servlet via Tomcat that creates a
person object and stuffs some personal info in it
that the person object is only created ONCE
and
that the personal info from user A is overwritten by user B's request?
that is my understanding of STATIC. Is this how Tomcat implements object
creation? I guess it makes sense in the stateless web ....
thanks in advance
Ray
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: one context per server
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Wed, 19 Jun 2002, Gabriel Mihalache wrote:
> Date: Wed, 19 Jun 2002 00:52:30 +0300
> From: Gabriel Mihalache <ga...@fx.ro>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat Users List <to...@jakarta.apache.org>
> Subject: one context per server
>
> is there a way to share a single JNDI context for all webapps?
Not with the standard implementation -- the JNDI context that Tomcat
provides is populated with the resources for that webapp, which can
potentially all be different.
With Tomcat 4.1.x, you can pretty easily share JNDI-accessed resources by
putting them in the <GlobalJNDIResources> element of server.xml, and
creating a <ResourceLink> element for each webapp -- so, for example, you
could declare a data source once and use it in multiple apps.
> can this context be accesible thru getServletContext() ?!
Nothing stops you from storing the JNDI initial context you get back as a
servlet context attribute, but it seems redundant to me -- the thing is
already accessible from anywhere in your code.
Craig
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>