crashing a Servlet

R

Roedy Green

Is there an official way to shutdown a Servlet so that it will load
new code? It seems that an uncaught NullPointerException will do it,
but that seems a little hokey.
 
D

Dan Gravell

Roedy said:
Is there an official way to shutdown a Servlet so that it will load
new code? It seems that an uncaught NullPointerException will do it,
but that seems a little hokey.

Don't understand the question. How do you mean load new code? The
Servlet class has a shutdown() method although that's called by the
container normally.
 
S

sks

Roedy Green said:
Is there an official way to shutdown a Servlet so that it will load
new code? It seems that an uncaught NullPointerException will do it,
but that seems a little hokey.

Do you mean getting the container to reload the servlet after you've made
changes? If so, that's down to your container config. Tomcat allows you to
set a reload scan time, which you can set to say 2s while developing, and 5
minutes otherwise.
 
W

William Brogden

Is there an official way to shutdown a Servlet so that it will load
new code? It seems that an uncaught NullPointerException will do it,
but that seems a little hokey.

Tomcat has a "Manager Application" that lets you force a given
application to be reloaded, plus a variety of other functions such as
showing how many current sessions an application has.

Its all documented in the Tomcat distribution.

Bill
 
J

Jeff Robertson

Roedy Green said:
Is there an official way to shutdown a Servlet so that it will load
new code? It seems that an uncaught NullPointerException will do it,
but that seems a little hokey.

I would expect that not only is hokey, but it's probably highly
container specific.

Unfortunately, everything about this question is going to be
container-specific anyway. There are some containers that auto-detect
new versions of servlet code and load it without you having to do
anything except drop the new class file in place. (And this may only
work if you have naked .class files in WEB-INF, no jars)

Many containers give you a way to restart an individual web
application from the command line or through some kind of admin
servlet. Still others, you just plain have to shut down the entire
server.
 
R

Roedy Green

Don't understand the question. How do you mean load new code? The
Servlet class has a shutdown() method although that's called by the
container normally.

The problem is often I change the code for a servlet. What I want to
happen in for Resin to notice, shut down the old servlet and start up
the new one. It often does this all by itself, but often it simply
refuses to notice. Sometimes even stopping and starting the service
will not suffice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top