You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ray Letts <rl...@etc.bc.ca> on 2002/06/19 00:00:23 UTC

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?"

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: 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>