Stop a servlet

tsuther
tsuther used Ask the Experts™
on
I am running Apache 2.0 and Tomcat 4.1.

I have a servlet that users can execute that does some work, forwards the response, and does some more work.  The work that the servlet does after the response is forwarded can take some time.  Because of this, I have the servlet add itself to an ArrayList that is a context attribute so that I can get a list of what is running.  I would like to be able to kill one of these servlets if I determine the job is having problems.

Is there a way to do this?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
After you take back the instance of the servlet from your list (ArrayList), you could call destroy() on the servlet.

Commented:
After you take back the instance of the servlet from your list (ArrayList), you could call destroy() on the servlet.

Author

Commented:
Would that not destroy every users process that was running this servlet?  I just want to stop it for that one user?
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Commented:
you could walk over to there desk and pull the power to there computer ;)
Java Developer
Top Expert 2010
Commented:
You shouldn't be storing the servlet and killing it, that is the job the the container.
Instead it sounds like you should be monitoring the processing threads and killing them if required.
Greetings,

   This sounds very difficult... i think we have some simple way to to that ? What you try to do is to stop the servet when there are some error occur, right ? Instead of "stop" why don't you forward or redirect to a global error page ? Show the error to the user, something like "Internal Server Error, please try to contact your system administrator." ...anyway, please correct me if i misunderstand your question.

hth,
Kok Choon.

   

Commented:
i personaly still like the power company solution.

Commented:
i kinda agree with objects. if your program has a problem and it has to die. or error out, then you should have your program check for where it might have a problem or something, maybe have it being managed by some parent class.

Sounds like a rough problem. good luck
You could create a "run" flag in your servlet that you check during your processing.  If the flag is true then execute, while a false flag would tell it to stop.  Then create a public routine you can execute to toggle the flag.  Therefore you could stop that particular servlet's processing without destroying the servlet.
tsuther:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between objects and thetool721

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Venabili
EE Cleanup Volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial