You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by paybackorfail <th...@hotmail.com> on 2009/02/14 20:45:34 UTC

starting and stoppping tomcat

Hi, I have written a web application in netbeans using java and jsp, and i am
hosting it on a server using tomcat, i need help on finding a way to start
and stop the server by the user clicking a button on a jsp page, do i have
to use the org.apache.catalina.ant.StartTask of the tomcat api? can anyone
help?
-- 
View this message in context: http://www.nabble.com/starting-and-stoppping-tomcat-tp22016214p22016214.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: starting and stoppping tomcat

Posted by Rusty Wright <ru...@gmail.com>.
Instead of trying to stop and start tomcat, would it help if your app used a more functional scheduling system?  For example, Quartz?

 http://www.opensymphony.com/quartz/wikidocs/FAQ.html


paybackorfail wrote:
> Hi, thanks for replying, my application will take some data from a website
> and insert this data into a database and i schedule the application to do
> this every hour using contextlistener and timertask as a java servlet. At
> the moment it starts updating the database as soon as i upload the
> application to the server, I need a way to shutdown the server so it will
> stop updating the database
> 
> 
> Alan Chaney wrote:
>> I think you need to rethink your use cases here...
>>
>> Exactly WHY do you need to start and stop tomcat from a button on a web 
>> page?
>> Or do you really need to enable/disable some kind of function?
>>
>> Generally speaking servers don't expect to be started or stopped by 
>> their clients - well, ok, sometimes you can stop a service by a client 
>> but almost by definition you can't start a service from a client...
>>
>> Typically tomcat provides a way of processing requests received from 
>> remote web clients and arranges for the requests to be processed by a 
>> web application. Your application may have state which can be controlled 
>> by the request. This shouldn't normally affect tomcat's normal operation.
>>
>> HTH
>>
>> Alan Chaney
>>
>>
>> paybackorfail wrote:
>>> That's a good point, what if it was just an html page?
>>>
>>>
>>> Mark Thomas-18 wrote:
>>>   
>>>> paybackorfail wrote:
>>>>     
>>>>> Hi, I have written a web application in netbeans using java and jsp,
>>>>> and
>>>>> i am
>>>>> hosting it on a server using tomcat, i need help on finding a way to
>>>>> start
>>>>> and stop the server by the user clicking a button on a jsp page, do i
>>>>> have
>>>>> to use the org.apache.catalina.ant.StartTask of the tomcat api? can
>>>>> anyone
>>>>> help?
>>>>>       
>>>> If Tomcat is stopped, how is it going to handle a user clicking on a
>>>> button on a JSP page to start it?
>>>>
>>>> Mark
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>>
>>>>     
>>>   
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: starting and stoppping tomcat

Posted by Alan Chaney <al...@compulsivecreative.com>.
My earlier point was that you need to think about it in a slightly 
different way.

Starting and stopping the server is something that is normally done 
rarely and anyway, you can't start something that is not already started 
by using it to start itself!

What you should do is to add a boolean flag - a state variable to your 
servlet. You can set or clear this flag with your page button.

Use this flag to condition your database access - so when the timer 
event fires, it checks the state flag and then accesses the database.


Regards

Alan


paybackorfail wrote:
> Hi, thanks for replying, my application will take some data from a website
> and insert this data into a database and i schedule the application to do
> this every hour using contextlistener and timertask as a java servlet. At
> the moment it starts updating the database as soon as i upload the
> application to the server, I need a way to shutdown the server so it will
> stop updating the database
> 
> 
> Alan Chaney wrote:
>> I think you need to rethink your use cases here...
>>
>> Exactly WHY do you need to start and stop tomcat from a button on a web 
>> page?
>> Or do you really need to enable/disable some kind of function?
>>
>> Generally speaking servers don't expect to be started or stopped by 
>> their clients - well, ok, sometimes you can stop a service by a client 
>> but almost by definition you can't start a service from a client...
>>
>> Typically tomcat provides a way of processing requests received from 
>> remote web clients and arranges for the requests to be processed by a 
>> web application. Your application may have state which can be controlled 
>> by the request. This shouldn't normally affect tomcat's normal operation.
>>
>> HTH
>>
>> Alan Chaney
>>
>>
>> paybackorfail wrote:
>>> That's a good point, what if it was just an html page?
>>>
>>>
>>> Mark Thomas-18 wrote:
>>>   
>>>> paybackorfail wrote:
>>>>     
>>>>> Hi, I have written a web application in netbeans using java and jsp,
>>>>> and
>>>>> i am
>>>>> hosting it on a server using tomcat, i need help on finding a way to
>>>>> start
>>>>> and stop the server by the user clicking a button on a jsp page, do i
>>>>> have
>>>>> to use the org.apache.catalina.ant.StartTask of the tomcat api? can
>>>>> anyone
>>>>> help?
>>>>>       
>>>> If Tomcat is stopped, how is it going to handle a user clicking on a
>>>> button on a JSP page to start it?
>>>>
>>>> Mark
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>>
>>>>     
>>>   
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: starting and stoppping tomcat

Posted by David Smith <dn...@cornell.edu>.
Your better off setting an application scope flag of some sort.  Then 
have a filter check the flag before letting the request through for 
processing.  If the flag is set, redirect to an unavailable page.

--David

paybackorfail wrote:
> Hi, thanks for replying, my application will take some data from a website
> and insert this data into a database and i schedule the application to do
> this every hour using contextlistener and timertask as a java servlet. At
> the moment it starts updating the database as soon as i upload the
> application to the server, I need a way to shutdown the server so it will
> stop updating the database
>
>
> Alan Chaney wrote:
>   
>> I think you need to rethink your use cases here...
>>
>> Exactly WHY do you need to start and stop tomcat from a button on a web 
>> page?
>> Or do you really need to enable/disable some kind of function?
>>
>> Generally speaking servers don't expect to be started or stopped by 
>> their clients - well, ok, sometimes you can stop a service by a client 
>> but almost by definition you can't start a service from a client...
>>
>> Typically tomcat provides a way of processing requests received from 
>> remote web clients and arranges for the requests to be processed by a 
>> web application. Your application may have state which can be controlled 
>> by the request. This shouldn't normally affect tomcat's normal operation.
>>
>> HTH
>>
>> Alan Chaney
>>
>>
>> paybackorfail wrote:
>>     
>>> That's a good point, what if it was just an html page?
>>>
>>>
>>> Mark Thomas-18 wrote:
>>>   
>>>       
>>>> paybackorfail wrote:
>>>>     
>>>>         
>>>>> Hi, I have written a web application in netbeans using java and jsp,
>>>>> and
>>>>> i am
>>>>> hosting it on a server using tomcat, i need help on finding a way to
>>>>> start
>>>>> and stop the server by the user clicking a button on a jsp page, do i
>>>>> have
>>>>> to use the org.apache.catalina.ant.StartTask of the tomcat api? can
>>>>> anyone
>>>>> help?
>>>>>       
>>>>>           
>>>> If Tomcat is stopped, how is it going to handle a user clicking on a
>>>> button on a JSP page to start it?
>>>>
>>>> Mark
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>>
>>>>     
>>>>         
>>>   
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>>     
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: starting and stoppping tomcat

Posted by paybackorfail <th...@hotmail.com>.
Hi, thanks for replying, my application will take some data from a website
and insert this data into a database and i schedule the application to do
this every hour using contextlistener and timertask as a java servlet. At
the moment it starts updating the database as soon as i upload the
application to the server, I need a way to shutdown the server so it will
stop updating the database


Alan Chaney wrote:
> 
> I think you need to rethink your use cases here...
> 
> Exactly WHY do you need to start and stop tomcat from a button on a web 
> page?
> Or do you really need to enable/disable some kind of function?
> 
> Generally speaking servers don't expect to be started or stopped by 
> their clients - well, ok, sometimes you can stop a service by a client 
> but almost by definition you can't start a service from a client...
> 
> Typically tomcat provides a way of processing requests received from 
> remote web clients and arranges for the requests to be processed by a 
> web application. Your application may have state which can be controlled 
> by the request. This shouldn't normally affect tomcat's normal operation.
> 
> HTH
> 
> Alan Chaney
> 
> 
> paybackorfail wrote:
>> That's a good point, what if it was just an html page?
>>
>>
>> Mark Thomas-18 wrote:
>>   
>>> paybackorfail wrote:
>>>     
>>>> Hi, I have written a web application in netbeans using java and jsp,
>>>> and
>>>> i am
>>>> hosting it on a server using tomcat, i need help on finding a way to
>>>> start
>>>> and stop the server by the user clicking a button on a jsp page, do i
>>>> have
>>>> to use the org.apache.catalina.ant.StartTask of the tomcat api? can
>>>> anyone
>>>> help?
>>>>       
>>> If Tomcat is stopped, how is it going to handle a user clicking on a
>>> button on a JSP page to start it?
>>>
>>> Mark
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>>     
>>
>>   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/starting-and-stoppping-tomcat-tp22016214p22017314.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: starting and stoppping tomcat

Posted by Alan Chaney <al...@compulsivecreative.com>.
I think you need to rethink your use cases here...

Exactly WHY do you need to start and stop tomcat from a button on a web 
page?
Or do you really need to enable/disable some kind of function?

Generally speaking servers don't expect to be started or stopped by 
their clients - well, ok, sometimes you can stop a service by a client 
but almost by definition you can't start a service from a client...

Typically tomcat provides a way of processing requests received from 
remote web clients and arranges for the requests to be processed by a 
web application. Your application may have state which can be controlled 
by the request. This shouldn't normally affect tomcat's normal operation.

HTH

Alan Chaney


paybackorfail wrote:
> That's a good point, what if it was just an html page?
>
>
> Mark Thomas-18 wrote:
>   
>> paybackorfail wrote:
>>     
>>> Hi, I have written a web application in netbeans using java and jsp, and
>>> i am
>>> hosting it on a server using tomcat, i need help on finding a way to
>>> start
>>> and stop the server by the user clicking a button on a jsp page, do i
>>> have
>>> to use the org.apache.catalina.ant.StartTask of the tomcat api? can
>>> anyone
>>> help?
>>>       
>> If Tomcat is stopped, how is it going to handle a user clicking on a
>> button on a JSP page to start it?
>>
>> Mark
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>>     
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: starting and stoppping tomcat

Posted by David Smith <dn...@cornell.edu>.
Still no good.  Some active code has to respond to a request to start 
the server.

--David

paybackorfail wrote:
> That's a good point, what if it was just an html page?
>
>
> Mark Thomas-18 wrote:
>   
>> paybackorfail wrote:
>>     
>>> Hi, I have written a web application in netbeans using java and jsp, and
>>> i am
>>> hosting it on a server using tomcat, i need help on finding a way to
>>> start
>>> and stop the server by the user clicking a button on a jsp page, do i
>>> have
>>> to use the org.apache.catalina.ant.StartTask of the tomcat api? can
>>> anyone
>>> help?
>>>       
>> If Tomcat is stopped, how is it going to handle a user clicking on a
>> button on a JSP page to start it?
>>
>> Mark
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>>     
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: starting and stoppping tomcat

Posted by André Warnier <aw...@ice-sa.com>.
My point below was that, to start Tomcat, you usually run a startup 
script, as root.
If you want to do that via a html page, then your html page must have 
something behind it - on the server - that runs as root to start Tomcat. 
  That's not a good idea.

But basically this is besides the point.  As the other posters wrote, 
what you need in your case is not to start and stop the whole Tomcat, 
just to be able to start and stop /one application/ inside Tomcat.  Or 
simply tell it whent it should be active (loading data in the database) 
or not.

André Warnier wrote:
> paybackorfail wrote:
>> That's a good point, what if it was just an html page?
>>
> Asking a question here is not really a substitute for thinking.
> 
> How are you starting Tomcat now ?
> 
>>
>> Mark Thomas-18 wrote:
>>> paybackorfail wrote:
>>>> Hi, I have written a web application in netbeans using java and jsp, 
>>>> and
>>>> i am
>>>> hosting it on a server using tomcat, i need help on finding a way to
>>>> start
>>>> and stop the server by the user clicking a button on a jsp page, do i
>>>> have
>>>> to use the org.apache.catalina.ant.StartTask of the tomcat api? can
>>>> anyone
>>>> help?
>>> If Tomcat is stopped, how is it going to handle a user clicking on a
>>> button on a JSP page to start it?
>>>
>>> Mark
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: starting and stoppping tomcat

Posted by André Warnier <aw...@ice-sa.com>.
paybackorfail wrote:
> That's a good point, what if it was just an html page?
> 
Asking a question here is not really a substitute for thinking.

How are you starting Tomcat now ?

> 
> Mark Thomas-18 wrote:
>> paybackorfail wrote:
>>> Hi, I have written a web application in netbeans using java and jsp, and
>>> i am
>>> hosting it on a server using tomcat, i need help on finding a way to
>>> start
>>> and stop the server by the user clicking a button on a jsp page, do i
>>> have
>>> to use the org.apache.catalina.ant.StartTask of the tomcat api? can
>>> anyone
>>> help?
>> If Tomcat is stopped, how is it going to handle a user clicking on a
>> button on a JSP page to start it?
>>
>> Mark
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: starting and stoppping tomcat

Posted by paybackorfail <th...@hotmail.com>.
That's a good point, what if it was just an html page?


Mark Thomas-18 wrote:
> 
> paybackorfail wrote:
>> Hi, I have written a web application in netbeans using java and jsp, and
>> i am
>> hosting it on a server using tomcat, i need help on finding a way to
>> start
>> and stop the server by the user clicking a button on a jsp page, do i
>> have
>> to use the org.apache.catalina.ant.StartTask of the tomcat api? can
>> anyone
>> help?
> 
> If Tomcat is stopped, how is it going to handle a user clicking on a
> button on a JSP page to start it?
> 
> Mark
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/starting-and-stoppping-tomcat-tp22016214p22016694.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: starting and stoppping tomcat

Posted by Mark Thomas <ma...@apache.org>.
paybackorfail wrote:
> Hi, I have written a web application in netbeans using java and jsp, and i am
> hosting it on a server using tomcat, i need help on finding a way to start
> and stop the server by the user clicking a button on a jsp page, do i have
> to use the org.apache.catalina.ant.StartTask of the tomcat api? can anyone
> help?

If Tomcat is stopped, how is it going to handle a user clicking on a
button on a JSP page to start it?

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org