*
The moose likes Servlets and the fly likes Stop Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Stop Servlet" Watch "Stop Servlet" New topic
Author

Stop Servlet

m baldo
Greenhorn

Joined: Jan 05, 2011
Posts: 8
Hallo all,
I have 3 different servlet running on tomcat 7.0.5, in one container (Record, Replay and Stop). Record give me the possibility to save information from web on my local disk. I can call different instance of Record, each return me data from different social network.
is it possible to mark every instance of Record servlet with a unique ID and stop a specific instance of that servlet (knowed by an ID passed by the URL) through the other servlet called Stop? If it is possible how i can take control of servlet using an ID through another servlet?
Thank you in advance, regards
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
I think you should back off a bit and create a different architecture. Recall that servlets are intended to service multiple requests "at the same time".

Bill
m baldo
Greenhorn

Joined: Jan 05, 2011
Posts: 8
Thank you bill, but do you think that i have to create 3 different web application running on tomcat and try to stop that using tomcat manager??
Can you give me a suggestion??
Thanks again
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Why are you talking about a servlet at all?

I can call different instance of Record, each return me data from different social network.


Sounds like you want to create a HTTP connection to a site like a browser does, not create a site that gets requests.

People frequently use something like the HttpClient toolkit to create connections emulating a browser.

Bill
m baldo
Greenhorn

Joined: Jan 05, 2011
Posts: 8
I need a servlet because i use the data returned by the program to create a stream of RDF quadruple instead of a snapshot of data, i extract useful information using sparql query on stream.
Because of this i need to start and stop servlet from remote, but i can't figure out how to stop a specific instance of servlet...
Thanks in advance for every help.
Aniruddh Joshi
Ranch Hand

Joined: Jul 29, 2008
Posts: 275

m baldo wrote:use the data returned by the program to create a stream of RDF quadruple instead of a snapshot of data, i extract useful information using sparql query on stream.


Sorry if I'm asking an odd question, but can't you do the above in a normal java program ?
Maybe if you elaborate the above i'll be able to suggest a solution.


Anrd
"One of the best things you could do is to simplify a larger application into a smaller one by reducing its process and complexity - Fowler"
m baldo
Greenhorn

Joined: Jan 05, 2011
Posts: 8
The connection to the social network and the manipulation of the data is done by a java program, but my goal is to make this program controllable via http, because of this i'm using servlet, the java program launched by the servlet in the future will be improved: more social network, more platform where to save data and more option about query engine. My problem is not the java program, it works very well, i need some help only with the servlet.
I can start the servlet using user parameter to do what he wants, but i don't know how to identify and stop a specific servlet instance.
Thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Controlling another program from a servlet is certainly possible, but why are you fixated on stopping and restarting the servlet?

A little thought on the architecture should get you a much more flexible and scalable design.


Bill
m baldo
Greenhorn

Joined: Jan 05, 2011
Posts: 8
Can i use ServletContext to save e pair: <id thread , something to identify and control thread>?
Does someone have suggestion on what is something to identify and control thread?
Thanks in advance, regards
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Should probably stop trying to use Servlet in this fashion and shift to moving whatever logic is in the Servlet classes to simple POJO business objects. You could still use a servlet to get to this logic, but will avoid the need to have to control specific instances of a particular servlet and introduce undesirable code.


A little thought on the architecture should get you a much more flexible and scalable design
Aniruddh Joshi
Ranch Hand

Joined: Jul 29, 2008
Posts: 275

what's the exact usecase when you want to stop the servlet ?
m baldo
Greenhorn

Joined: Jan 05, 2011
Posts: 8
In my servlet thread i call a java programs that return me useful data.
I can stop the right servlet thread using the servletcontext to save the right information, but how can i stop all the thread of the java program that i have created into the servlet main thread (these are not a cild thread of the main one)?
Thanks in advance, regards
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Exactly what Thread do you think needs to be stopped?

A "running" servlet container has a Thread that gets a port connection attempt and turns it into a HTTP request from a client then hands off the request processing to a Thread that is dedicated to creating a response to that request. Using a request Thread for extended processing is a really bad idea.

When multiple experienced servlet programmers tell you that you are on the wrong track, don't you think it might be a good idea to listen to them?

Bill
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

William Brogden wrote:When multiple experienced servlet programmers tell you that you are on the wrong track, don't you think it might be a good idea to listen to them?


Just in case one more voice will help: m baldo, you're on the wrong track!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stop Servlet