I see what you mean.
So it seems that the only solution to be sure a class is not unloaded is to make
your own class loader for that class. Unfortunately, this solution can not be
applied to a servlet.
Lachezar Dobrev wrote:
Hello,
Your objection makes sense, but here is sometrinh from the
I see what you mean.
Good.
So it seems that the only solution to be sure a class is not unloaded is
to make
your own class loader for that class. Unfortunately, this solution can not
be
applied to a servlet.
Or make a singleton to keep the class loaded. I do this, and it works.
Even
At 04:11 25/07/2001 -0700, you wrote:
Ismael,
Beware of static variables in servlets.
Use application level variables...initialized from the init(). Put this in
any servlet, just as long as its used at least once.
public void init(ServletConfig config) throws ServletException {
Hi,
If you want to synchronize access to your static variable, you need to
synchronize with respect to the class, not the application. Something like
this should work:
synchronized (this.getClass()) {
// Your code
}
Cheers,
Luis.
- Original Message -
From: Ismael
To:
You see, your scenario couldn't exactly happen:
The garbage collector cleans all class instances (in this case only one
instance), but not the class itself. The class loader does not unload the class
bytecode, and the static fields do not reside in any of the class instances that
are released by
Within the servlet container you will only have one instance of the servlet
class so there is no need to use static variables. Other people have made good
points that if the container tosses out the servlet instead of serializing it
for later use the classloader will re-initialize the counter.
Hello,
Your objection makes sense, but here is sometrinh from the JVM specification
from SUN:
2.17.8Unloading of Classes and Interfaces A class or interface may be
unloaded if and only if its class loader is unreachable.
The bootstrap class loader is always reachable; as a result, system
Hello,
Your objection makes sense, but here is sometrinh from the JVM
specification
from SUN:
2.17.8Unloading of Classes and Interfaces A class or interface may be
unloaded if and only if its class loader is unreachable.
The bootstrap class loader is always reachable; as a result,
Ismael,
Beware of static variables in servlets.
Use application level variables...initialized from the init(). Put this in
any servlet, just as long as its used at least once.
public void init(ServletConfig config) throws ServletException {
super.init(config);
Long counter
Hi.
This MAY be totally wrong, but I have seen that in a different place in a
different problem, in a different need. I got the same thing.
Problem: Static varialbles are being reset from time to time.
My Answer: The lifetime of the Servlets/EJBs/JSPs is defined by how the
Instead of static I would use a member attribute, since for servlets
only one instance exists for a given class.
Ismael wrote:
I am making some loading tests, in order to test the loading tool I
have written some special jsp to deal verify the number of times a jsp
has been called.
My jsp
Just a question man... how do you send messages to the mailinglist? The orionserver
mailinglist I mean.
12 matches
Mail list logo