You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Marc-Oliver Scheele <sc...@searchbroker.de> on 2000/10/07 17:50:53 UTC

access to static-members

Hello;

We are using Tomcat3.1; Java1.2.2; Wind NT4.0 SP5.

There seems to be an unexpected behavior when using
static variables in a servlet-application.

The application uses several different servlets (and aggregated classes).
Some of them defines static-variables that are
accessed for data-exchange by other servlets.

The problem is that sometimes one servlet is able to
read the right content of a static-variable, but 
sometimes (another servlet) couldn't read it.

For example:

- StaticClass.var  (is set to)  "Hello";
- ServletA:
System.out.println(StaticClass.var)    --> "Hello" to Stdout
- ServletB:
System.out.println(StaticClass.var)    --> "null" to Stdout

Any ideas?
Is there problem with the class-loader?

Help is appreciated

Greetings
mos

Re: access to static-members

Posted by "Pier P. Fumagalli" <pi...@betaversion.org>.
Where is StaticClass, ServletA and ServletB? All in the same package
loaded by the same classloader (like in the same webapp?)

	Pier

Marc-Oliver Scheele wrote:
> 
> Hello;
> 
> We are using Tomcat3.1; Java1.2.2; Wind NT4.0 SP5.
> 
> There seems to be an unexpected behavior when using
> static variables in a servlet-application.
> 
> The application uses several different servlets (and aggregated classes).
> Some of them defines static-variables that are
> accessed for data-exchange by other servlets.
> 
> The problem is that sometimes one servlet is able to
> read the right content of a static-variable, but
> sometimes (another servlet) couldn't read it.
> 
> For example:
> 
> - StaticClass.var  (is set to)  "Hello";
> - ServletA:
> System.out.println(StaticClass.var)    --> "Hello" to Stdout
> - ServletB:
> System.out.println(StaticClass.var)    --> "null" to Stdout
> 
> Any ideas?
> Is there problem with the class-loader?
> 
> Help is appreciated
> 
> Greetings
> mos
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org