You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tom Potter <nu...@gmail.com> on 2006/07/13 14:27:50 UTC

Run shell script when web application start/restart

The JSP pages in the Web application I install under Tomcat 4.1.30
are based on some configuration files the user wants to modify, thus
I wrote a shell script to rebuild the JSP pages and repopulate
the webapps folder.

My question is that is there a way to hook up my shell script with the
webapp start/stop proces so it would run at every startup, in other
words the user would activate my script by restarting the application ?

Thanks
Thomas

Re: Run shell script when web application start/restart

Posted by Avi Deitcher <av...@deitcher.net>.
Richard,

I think he is discussing a 2-step process. First the JSP pages are
*generated* via some shell script, then they are *compiled* from the JSP
source by Tomcat. that is why I suggested inverting it, having the JSPs
fully formed, but have them pull config info as necessary.

Richard Mixon wrote:

>Maybe I'm missing something, but if you re-generate the pages, and have
>Tomcat in development mode, the new pages will automatically be re-compiled
>the next time they are accessed. 
>
>-----Original Message-----
>From: Tom Potter [mailto:nullpointer.gpf@gmail.com] 
>Sent: Thursday, July 13, 2006 7:59 AM
>To: Tomcat Users List
>Subject: Re: Run shell script when web application start/restart
>
>The reason for me choosing the first, messy solution was that this had to be
>a quick fix, rewriting the logic in the JSP pages was out of the question
>(and way above the allocated budget ;) ).
>
>Of course I had the shell scripts and configuration files so it seemed just
>the right solution to  use these tools in the startup process of the webapp.
>
>It seems that I can convince the cusomer to just run the shell scripts that
>modify(actually generate) the JSP pages but then I face an other problem.
>After generating and copying the JSP pages in the right place how can I tell
>tomcat (from the shell script) to restart the application (or to recompile
>the pages) ?
>
>Rgds
>Thomas
>
>On 7/13/06, Avi Deitcher <av...@deitcher.net> wrote:
>  
>
>>I don't think so. You could, theoretically, have a context listener 
>>that then executes a shell script, but that is really messy, and the 
>>security manager probably won't even allow it.
>>
>>If I understand correctly, you want to have the following happen on 
>>context restart:
>>- JSP pages get rebuilt from some macros or config files
>>
>>I can think of two ways to do this. The not-so-great way is to have a 
>>context listener read the config files and generate the pages. The 
>>problem is that I don't know when JSP pages are compiled by the Tomcat 
>>engine - before or after context listeners are invoked. I believe you 
>>can force a re-compilation of the JSP pages at that point, but I am 
>>not sure how.
>>
>>The much smarter way is to ask why your JSP pages need to be 
>>macro/dynamically generated. JSP includes enough logic tags. Why not 
>>refactor your JSP pages so that they read the configuration files and 
>>output the appropriate information? This would be much cleaner, and 
>>probably wouldn't even require context restart?
>>
>>Tom Potter wrote:
>>
>>    
>>
>>>Jen,
>>>
>>>Just to make sure that we both talk about the same events :
>>>I don't want to restart the whole tomcat, only one web application, 
>>>that is, by clicking on the start link(or restart) in on the admin page.
>>>I don't see how your suggestion would help me... if I'm missing 
>>>something please make it clear to me...
>>>
>>>Rgds
>>>Thomas
>>>
>>>On 7/13/06, Mead, Jennifer L - VSCM <Me...@vectorscm.com> wrote:
>>>
>>>      
>>>
>>>>On my box the start and stop scripts are just that.  .sh shell scripts.
>>>>In your case I would just copy them to a save file and put in an 
>>>>execution string.  The start scripts are in tomcat_home/bin.
>>>>
>>>>Jen
>>>>
>>>>-----Original Message-----
>>>>From: Tom Potter [mailto:nullpointer.gpf@gmail.com]
>>>>Sent: Thursday, July 13, 2006 5:28 AM
>>>>To: users@tomcat.apache.org
>>>>Subject: Run shell script when web application start/restart
>>>>
>>>>The JSP pages in the Web application I install under Tomcat 4.1.30 
>>>>are based on some configuration files the user wants to modify, 
>>>>thus I
>>>>        
>>>>
>>wrote
>>    
>>
>>>>a shell script to rebuild the JSP pages and repopulate the webapps 
>>>>folder.
>>>>
>>>>My question is that is there a way to hook up my shell script with 
>>>>the webapp start/stop proces so it would run at every startup, in 
>>>>other words the user would activate my script by restarting the
>>>>        
>>>>
>application ?
>  
>
>>>>Thanks
>>>>Thomas
>>>>
>>>>-------------------------------------------------------------------
>>>>-- To start a new topic, e-mail: users@tomcat.apache.org To 
>>>>unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>>        
>>>>
>>--
>>______________________________
>>Avi Deitcher
>>avi@deitcher.net
>>
>>
>>
>>---------------------------------------------------------------------
>>To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, 
>>e-mail: users-unsubscribe@tomcat.apache.org
>>For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>  
>

-- 
______________________________
Avi Deitcher
avi@deitcher.net



RE: Run shell script when web application start/restart

Posted by Richard Mixon <rn...@qwest.net>.
Maybe I'm missing something, but if you re-generate the pages, and have
Tomcat in development mode, the new pages will automatically be re-compiled
the next time they are accessed. 

-----Original Message-----
From: Tom Potter [mailto:nullpointer.gpf@gmail.com] 
Sent: Thursday, July 13, 2006 7:59 AM
To: Tomcat Users List
Subject: Re: Run shell script when web application start/restart

The reason for me choosing the first, messy solution was that this had to be
a quick fix, rewriting the logic in the JSP pages was out of the question
(and way above the allocated budget ;) ).

Of course I had the shell scripts and configuration files so it seemed just
the right solution to  use these tools in the startup process of the webapp.

It seems that I can convince the cusomer to just run the shell scripts that
modify(actually generate) the JSP pages but then I face an other problem.
After generating and copying the JSP pages in the right place how can I tell
tomcat (from the shell script) to restart the application (or to recompile
the pages) ?

Rgds
Thomas

On 7/13/06, Avi Deitcher <av...@deitcher.net> wrote:
>
> I don't think so. You could, theoretically, have a context listener 
> that then executes a shell script, but that is really messy, and the 
> security manager probably won't even allow it.
>
> If I understand correctly, you want to have the following happen on 
> context restart:
> - JSP pages get rebuilt from some macros or config files
>
> I can think of two ways to do this. The not-so-great way is to have a 
> context listener read the config files and generate the pages. The 
> problem is that I don't know when JSP pages are compiled by the Tomcat 
> engine - before or after context listeners are invoked. I believe you 
> can force a re-compilation of the JSP pages at that point, but I am 
> not sure how.
>
> The much smarter way is to ask why your JSP pages need to be 
> macro/dynamically generated. JSP includes enough logic tags. Why not 
> refactor your JSP pages so that they read the configuration files and 
> output the appropriate information? This would be much cleaner, and 
> probably wouldn't even require context restart?
>
> Tom Potter wrote:
>
> > Jen,
> >
> > Just to make sure that we both talk about the same events :
> > I don't want to restart the whole tomcat, only one web application, 
> > that is, by clicking on the start link(or restart) in on the admin page.
> > I don't see how your suggestion would help me... if I'm missing 
> > something please make it clear to me...
> >
> > Rgds
> > Thomas
> >
> > On 7/13/06, Mead, Jennifer L - VSCM <Me...@vectorscm.com> wrote:
> >
> >>
> >> On my box the start and stop scripts are just that.  .sh shell scripts.
> >> In your case I would just copy them to a save file and put in an 
> >> execution string.  The start scripts are in tomcat_home/bin.
> >>
> >> Jen
> >>
> >> -----Original Message-----
> >> From: Tom Potter [mailto:nullpointer.gpf@gmail.com]
> >> Sent: Thursday, July 13, 2006 5:28 AM
> >> To: users@tomcat.apache.org
> >> Subject: Run shell script when web application start/restart
> >>
> >> The JSP pages in the Web application I install under Tomcat 4.1.30 
> >> are based on some configuration files the user wants to modify, 
> >> thus I
> wrote
> >> a shell script to rebuild the JSP pages and repopulate the webapps 
> >> folder.
> >>
> >> My question is that is there a way to hook up my shell script with 
> >> the webapp start/stop proces so it would run at every startup, in 
> >> other words the user would activate my script by restarting the
application ?
> >>
> >> Thanks
> >> Thomas
> >>
> >> -------------------------------------------------------------------
> >> -- To start a new topic, e-mail: users@tomcat.apache.org To 
> >> unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
>
> --
> ______________________________
> Avi Deitcher
> avi@deitcher.net
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, 
> e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


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


Re: Run shell script when web application start/restart

Posted by Avi Deitcher <av...@deitcher.net>.
Well, if you have to, from the shell script, you can probably connect to
the tomcat manager URL and tell it to do the right thing. Still, all and
all, it is hard to believe it isn't faster to refactor the JSP pages.

Tom Potter wrote:

> The reason for me choosing the first, messy solution was that
> this had to be a quick fix, rewriting the logic in the JSP pages
> was out of the question (and way above the allocated budget ;) ).
>
> Of course I had the shell scripts and configuration files so it
> seemed just the right solution to  use these tools in the startup
> process of the webapp.
>
> It seems that I can convince the cusomer to just run the shell
> scripts that modify(actually generate) the JSP pages but then I face
> an other problem. After generating and copying the JSP pages in the
> right place how can I tell tomcat (from the shell script) to restart
> the application (or to recompile the pages) ?
>
> Rgds
> Thomas
>
> On 7/13/06, Avi Deitcher <av...@deitcher.net> wrote:
>
>>
>> I don't think so. You could, theoretically, have a context listener that
>> then executes a shell script, but that is really messy, and the security
>> manager probably won't even allow it.
>>
>> If I understand correctly, you want to have the following happen on
>> context restart:
>> - JSP pages get rebuilt from some macros or config files
>>
>> I can think of two ways to do this. The not-so-great way is to have a
>> context listener read the config files and generate the pages. The
>> problem is that I don't know when JSP pages are compiled by the Tomcat
>> engine - before or after context listeners are invoked. I believe you
>> can force a re-compilation of the JSP pages at that point, but I am not
>> sure how.
>>
>> The much smarter way is to ask why your JSP pages need to be
>> macro/dynamically generated. JSP includes enough logic tags. Why not
>> refactor your JSP pages so that they read the configuration files and
>> output the appropriate information? This would be much cleaner, and
>> probably wouldn't even require context restart?
>>
>> Tom Potter wrote:
>>
>> > Jen,
>> >
>> > Just to make sure that we both talk about the same events :
>> > I don't want to restart the whole tomcat, only one web application,
>> > that is, by clicking on the start link(or restart) in on the admin
>> page.
>> > I don't see how your suggestion would help me... if I'm missing
>> > something please make it clear to me...
>> >
>> > Rgds
>> > Thomas
>> >
>> > On 7/13/06, Mead, Jennifer L - VSCM <Me...@vectorscm.com>
>> wrote:
>> >
>> >>
>> >> On my box the start and stop scripts are just that.  .sh shell
>> scripts.
>> >> In your case I would just copy them to a save file and put in an
>> >> execution string.  The start scripts are in tomcat_home/bin.
>> >>
>> >> Jen
>> >>
>> >> -----Original Message-----
>> >> From: Tom Potter [mailto:nullpointer.gpf@gmail.com]
>> >> Sent: Thursday, July 13, 2006 5:28 AM
>> >> To: users@tomcat.apache.org
>> >> Subject: Run shell script when web application start/restart
>> >>
>> >> The JSP pages in the Web application I install under Tomcat 4.1.30
>> are
>> >> based on some configuration files the user wants to modify, thus I
>> wrote
>> >> a shell script to rebuild the JSP pages and repopulate the webapps
>> >> folder.
>> >>
>> >> My question is that is there a way to hook up my shell script with
>> the
>> >> webapp start/stop proces so it would run at every startup, in other
>> >> words the user would activate my script by restarting the
>> application ?
>> >>
>> >> Thanks
>> >> Thomas
>> >>
>> >> ---------------------------------------------------------------------
>> >> To start a new topic, e-mail: users@tomcat.apache.org
>> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> >> For additional commands, e-mail: users-help@tomcat.apache.org
>> >>
>> >>
>> >
>>
>> -- 
>> ______________________________
>> Avi Deitcher
>> avi@deitcher.net
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>

-- 
______________________________
Avi Deitcher
avi@deitcher.net



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


Re: Run shell script when web application start/restart

Posted by Tom Potter <nu...@gmail.com>.
The reason for me choosing the first, messy solution was that
this had to be a quick fix, rewriting the logic in the JSP pages
was out of the question (and way above the allocated budget ;) ).

Of course I had the shell scripts and configuration files so it
seemed just the right solution to  use these tools in the startup
process of the webapp.

It seems that I can convince the cusomer to just run the shell
scripts that modify(actually generate) the JSP pages but then I face
an other problem. After generating and copying the JSP pages in the
right place how can I tell tomcat (from the shell script) to restart
the application (or to recompile the pages) ?

Rgds
Thomas

On 7/13/06, Avi Deitcher <av...@deitcher.net> wrote:
>
> I don't think so. You could, theoretically, have a context listener that
> then executes a shell script, but that is really messy, and the security
> manager probably won't even allow it.
>
> If I understand correctly, you want to have the following happen on
> context restart:
> - JSP pages get rebuilt from some macros or config files
>
> I can think of two ways to do this. The not-so-great way is to have a
> context listener read the config files and generate the pages. The
> problem is that I don't know when JSP pages are compiled by the Tomcat
> engine - before or after context listeners are invoked. I believe you
> can force a re-compilation of the JSP pages at that point, but I am not
> sure how.
>
> The much smarter way is to ask why your JSP pages need to be
> macro/dynamically generated. JSP includes enough logic tags. Why not
> refactor your JSP pages so that they read the configuration files and
> output the appropriate information? This would be much cleaner, and
> probably wouldn't even require context restart?
>
> Tom Potter wrote:
>
> > Jen,
> >
> > Just to make sure that we both talk about the same events :
> > I don't want to restart the whole tomcat, only one web application,
> > that is, by clicking on the start link(or restart) in on the admin page.
> > I don't see how your suggestion would help me... if I'm missing
> > something please make it clear to me...
> >
> > Rgds
> > Thomas
> >
> > On 7/13/06, Mead, Jennifer L - VSCM <Me...@vectorscm.com> wrote:
> >
> >>
> >> On my box the start and stop scripts are just that.  .sh shell scripts.
> >> In your case I would just copy them to a save file and put in an
> >> execution string.  The start scripts are in tomcat_home/bin.
> >>
> >> Jen
> >>
> >> -----Original Message-----
> >> From: Tom Potter [mailto:nullpointer.gpf@gmail.com]
> >> Sent: Thursday, July 13, 2006 5:28 AM
> >> To: users@tomcat.apache.org
> >> Subject: Run shell script when web application start/restart
> >>
> >> The JSP pages in the Web application I install under Tomcat 4.1.30 are
> >> based on some configuration files the user wants to modify, thus I
> wrote
> >> a shell script to rebuild the JSP pages and repopulate the webapps
> >> folder.
> >>
> >> My question is that is there a way to hook up my shell script with the
> >> webapp start/stop proces so it would run at every startup, in other
> >> words the user would activate my script by restarting the application ?
> >>
> >> Thanks
> >> Thomas
> >>
> >> ---------------------------------------------------------------------
> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
>
> --
> ______________________________
> Avi Deitcher
> avi@deitcher.net
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Run shell script when web application start/restart

Posted by Avi Deitcher <av...@deitcher.net>.
I don't think so. You could, theoretically, have a context listener that
then executes a shell script, but that is really messy, and the security
manager probably won't even allow it.

If I understand correctly, you want to have the following happen on
context restart:
- JSP pages get rebuilt from some macros or config files

I can think of two ways to do this. The not-so-great way is to have a
context listener read the config files and generate the pages. The
problem is that I don't know when JSP pages are compiled by the Tomcat
engine - before or after context listeners are invoked. I believe you
can force a re-compilation of the JSP pages at that point, but I am not
sure how.

The much smarter way is to ask why your JSP pages need to be
macro/dynamically generated. JSP includes enough logic tags. Why not
refactor your JSP pages so that they read the configuration files and
output the appropriate information? This would be much cleaner, and
probably wouldn't even require context restart?

Tom Potter wrote:

> Jen,
>
> Just to make sure that we both talk about the same events :
> I don't want to restart the whole tomcat, only one web application,
> that is, by clicking on the start link(or restart) in on the admin page.
> I don't see how your suggestion would help me... if I'm missing
> something please make it clear to me...
>
> Rgds
> Thomas
>
> On 7/13/06, Mead, Jennifer L - VSCM <Me...@vectorscm.com> wrote:
>
>>
>> On my box the start and stop scripts are just that.  .sh shell scripts.
>> In your case I would just copy them to a save file and put in an
>> execution string.  The start scripts are in tomcat_home/bin.
>>
>> Jen
>>
>> -----Original Message-----
>> From: Tom Potter [mailto:nullpointer.gpf@gmail.com]
>> Sent: Thursday, July 13, 2006 5:28 AM
>> To: users@tomcat.apache.org
>> Subject: Run shell script when web application start/restart
>>
>> The JSP pages in the Web application I install under Tomcat 4.1.30 are
>> based on some configuration files the user wants to modify, thus I wrote
>> a shell script to rebuild the JSP pages and repopulate the webapps
>> folder.
>>
>> My question is that is there a way to hook up my shell script with the
>> webapp start/stop proces so it would run at every startup, in other
>> words the user would activate my script by restarting the application ?
>>
>> Thanks
>> Thomas
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>

-- 
______________________________
Avi Deitcher
avi@deitcher.net



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


Re: Run shell script when web application start/restart

Posted by Tom Potter <nu...@gmail.com>.
Jen,

Just to make sure that we both talk about the same events :
I don't want to restart the whole tomcat, only one web application,
that is, by clicking on the start link(or restart) in on the admin page.
I don't see how your suggestion would help me... if I'm missing
something please make it clear to me...

Rgds
Thomas

On 7/13/06, Mead, Jennifer L - VSCM <Me...@vectorscm.com> wrote:
>
> On my box the start and stop scripts are just that.  .sh shell scripts.
> In your case I would just copy them to a save file and put in an
> execution string.  The start scripts are in tomcat_home/bin.
>
> Jen
>
> -----Original Message-----
> From: Tom Potter [mailto:nullpointer.gpf@gmail.com]
> Sent: Thursday, July 13, 2006 5:28 AM
> To: users@tomcat.apache.org
> Subject: Run shell script when web application start/restart
>
> The JSP pages in the Web application I install under Tomcat 4.1.30 are
> based on some configuration files the user wants to modify, thus I wrote
> a shell script to rebuild the JSP pages and repopulate the webapps
> folder.
>
> My question is that is there a way to hook up my shell script with the
> webapp start/stop proces so it would run at every startup, in other
> words the user would activate my script by restarting the application ?
>
> Thanks
> Thomas
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

RE: Run shell script when web application start/restart

Posted by "Mead, Jennifer L - VSCM" <Me...@vectorscm.com>.
On my box the start and stop scripts are just that.  .sh shell scripts.
In your case I would just copy them to a save file and put in an
execution string.  The start scripts are in tomcat_home/bin.  

Jen 

-----Original Message-----
From: Tom Potter [mailto:nullpointer.gpf@gmail.com] 
Sent: Thursday, July 13, 2006 5:28 AM
To: users@tomcat.apache.org
Subject: Run shell script when web application start/restart

The JSP pages in the Web application I install under Tomcat 4.1.30 are
based on some configuration files the user wants to modify, thus I wrote
a shell script to rebuild the JSP pages and repopulate the webapps
folder.

My question is that is there a way to hook up my shell script with the
webapp start/stop proces so it would run at every startup, in other
words the user would activate my script by restarting the application ?

Thanks
Thomas

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