users@glassfish.java.net

Re: Interrupting a running Servlet

From: <glassfish_at_javadesktop.org>
Date: Tue, 01 Apr 2008 06:07:04 PST

Well this is a glassfish forum, so you probably should post your question on tomcats user mailing list.

Nevertheless some remarks. Long lasting servlets are a bad idea - unless you use a NIO-based connector. GF has one and Tomcat 6 has one as well. But you really should use a NIO-based connector if your servlet really waits for the C-app to end. When using blocking connectors your are consuming valuable (and limited - thought the limit itself can be adjusted) threads.

You cannot "connect" back to a previous request. If this C-app can run more than once you need to transfer the PID back and forth and call the correct process in a completely unrelated servlet thread to stop. And you should be very careful to not cause a security nightmare with this design! If it can run only once on the machine there is no need to connect back to your other thread (or at least I cannot see why you want to do so). Just issue the stop-call and - voila - you're done. What am I missing here? And why is the first servlet waiting for the C-app to end in the first place?

There are also some other subtleties to consider: A browser can only open two connections to the same server at any given time (without using hacks). So if one is already a long-lasting request you must ensure that the second request is not long-lasting as well. Otherwise you cannot connect from this browser to your server until you restart your browser or your browser hits a timeout.

As already stated I recommend to contact the tomcat user mailing list. Otherwise it would be wise to give us some more background about the purpose of your app so that we can help you.

--
Wolfram Rittmeyer
[Message sent by forum member 'writtmeyer' (writtmeyer)]
http://forums.java.net/jive/thread.jspa?messageID=267065