You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Frank Niedermann <fb...@thelogic.org> on 2006/09/20 10:11:46 UTC

Precompiled JSPs after Tomcat restart

Hello,

is it right that Tomcat stores all compiled JSP sites in
Tomcat5\work\Catalina\localhost\application\org\apache\jsp?

After a restart of Tomcat I still see all the .class files
in above mentioned directory, does that mean that these files
do not have to be compiled again at first access to them?

My application always seems to be slower after Tomcat restarts
so I'm wondering what reason this behavior could have?

Regards,
  Frank


---------------------------------------------------------------------
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: Precompiled JSPs after Tomcat restart

Posted by Frank Niedermann <fb...@thelogic.org>.


Tracy Nelson-2 wrote:
> 
> You might be able to preload all your JSPs by using the
> <load-on-startup> tag.  Something like:
> <servlet>
>     <servlet-name>MyServlet</servlet-name>
>     <jsp-file>/jsp/MyPage.jsp</jsp-file>
>     <load-on-startup>1</load-on-startup>
> </servlet>
> 

How will this preload all JSPs? Or do I have to add a <servlet>
realm for every JSP I want to precompile?



> Failing that, you might want to check out the Jakarta mini-browser, or a
> text-based browser like Lynx.  It should be possible to script either
> one of these to visit all your pages.  If you're worried about
> interactions, or if security is an issue (e.g., you can't access pages
> unless you log in), you might want to add a parameter like
> "?preload=true" to the URL, and have your JSPs or servlets Do The Right
> Thing when they see it. 
> 

Adding a new parameter is not possible as we have to deploy a finished
application from MatrixOne. Changing every JSP would generate huge
problems with them.

The idea with lynx is nice, combined with a find command would this
be a good solution :-)

Frank
-- 
View this message in context: http://www.nabble.com/Precompiled-JSPs-after-Tomcat-restart-tf2303735.html#a6523601
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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: Precompiled JSPs after Tomcat restart

Posted by Tracy Nelson <tn...@factsmgt.com>.
I'm not sure how long Tomcat will cache the JSP, I would assume that
it's dependent on how you've got your site configured (how much heap
space you have allocated), how many servlets/JSPs you have and what kind
of usage patterns you see.  I would guess that Tomcat will unload
servlets if memory gets tight, starting with the least-recently-accessed
first.  Remember, though, that only one instance of the servlet is ever
loaded, so even if your servlet is getting hundreds of hits a minute,
your memory usage shouldn't climb that fast.

You might be able to preload all your JSPs by using the
<load-on-startup> tag.  Something like:

<servlet>
    <servlet-name>MyServlet</servlet-name>
    <jsp-file>/jsp/MyPage.jsp</jsp-file>
    <load-on-startup>1</load-on-startup>
</servlet>

Failing that, you might want to check out the Jakarta mini-browser, or a
text-based browser like Lynx.  It should be possible to script either
one of these to visit all your pages.  If you're worried about
interactions, or if security is an issue (e.g., you can't access pages
unless you log in), you might want to add a parameter like
"?preload=true" to the URL, and have your JSPs or servlets Do The Right
Thing when they see it.  That's starting to get a little involved,
though...

---
Tracy Nelson / Nelnet Business Solutions
402 / 617-9449

| -----Original Message-----
| From: Frank Niedermann [mailto:fbn@thelogic.org]
| Sent: Tuesday, 26 September, 2006 00:50
| To: users@tomcat.apache.org
| Subject: RE: Precompiled JSPs after Tomcat restart
| 
| 
| Tracy,
| 
| thanks for clarification.
| 
| How long will Tomcat cache a loaded JSP?
| 
| And is there a way to tell Tomcat or the classloader to load every
| single JSP after startup?
| 
| Do you have an example of such a script? (ATM I have no idea how
| to do this)
| 
| Thanks,
|   Frank
| 
| Do you
| 
| Tracy Nelson-2 wrote:
| >
| > What you're seeing is normal servlet/JSP processing.  After you
restart
| > Tomcat, the classloader has to load the servlet/JSP.  Once it has
done
| > this, the servlet/JSP is cached so it doesn't need to be reloaded.
The
| > JSP files shouldn't be compiled again unless they change.  The
server
| > should check the last-modified time on the JSP when it receives a
| > request, and compare that to the creation time of the compiled
class,
| > and recompile if necessary.
| >
| > If you can (depending on how complex your application is), you might
| > want to create a small script to access every page in your
application,
| > then run that as the last step in your Tomcat startup script.  It
| > doesn't matter if the page is accessed "correctly" (i.e., passed any
| > parameters it needs), it'll still be loaded and cached.
| >
| > ---
| > Tracy Nelson / Nelnet Business Solutions
| > 402 / 617-9449
| >
| > | -----Original Message-----
| > | From: Frank Niedermann [mailto:fbn@thelogic.org]
| > | Sent: Monday, 25 September, 2006 04:48
| > | To: users@tomcat.apache.org
| > | Subject: Re: Precompiled JSPs after Tomcat restart
| > |
| > |
| > | I've found the .java and .class files in a new sample application.
| > |
| > | I still don't understand if the compiled class files are used
after
| > | Tomcat restart or if the JSP files will get compiled again.
| > |
| > | I'm asking because my application (Matrix from MatrixOne) is
| > | very slow after restarting Tomcat. After visiting (and compiling?)
| > | every JSP page it gets faster until next Tomcat restart.
| > |
| > | Can anybody clarify or help me out with hints to documentation?
| > |
| > | Thanks.
| > |
| > |
| > | Michael Zoller wrote:
| > | > Frank Niedermann wrote:
| > | >> Hello,
| > | >>
| > | >> is it right that Tomcat stores all compiled JSP sites in
| > | >> Tomcat5\work\Catalina\localhost\application\org\apache\jsp?
| > | >>
| > | > yes.
| > | >> After a restart of Tomcat I still see all the .class files
| > | >> in above mentioned directory, does that mean that these files
| > | >> do not have to be compiled again at first access to them?
| > | >>
| > | > Educated guess: The servlets/jsp still have to be executed. Once
| > they
| > | > are loaded into memory they will execute faster because caching
| > | > mechanisms (harddisk and OS) apply.
| > | >
| > | >
| > | > Michael
| > | >
| > | >
| >
---------------------------------------------------------------------
| > | > 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
| > |
| > |
| > |
| > |
| > |
| > |
| > | --
| > | View this message in context:
http://www.nabble.com/Precompiled-JSPs-
| > | after-Tomcat-restart-tf2303735.html#a6483314
| > | Sent from the Tomcat - User mailing list archive at Nabble.com.
| > |
| > |
| > |
---------------------------------------------------------------------
| > | 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
| >
| >
| >
| 
| --
| View this message in context: http://www.nabble.com/Precompiled-JSPs-
| after-Tomcat-restart-tf2303735.html#a6500771
| Sent from the Tomcat - User mailing list archive at Nabble.com.
| 
| 
| ---------------------------------------------------------------------
| 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: Precompiled JSPs after Tomcat restart

Posted by Frank Niedermann <fb...@thelogic.org>.
Tracy,

thanks for clarification. 

How long will Tomcat cache a loaded JSP?

And is there a way to tell Tomcat or the classloader to load every
single JSP after startup?

Do you have an example of such a script? (ATM I have no idea how
to do this)

Thanks,
  Frank

Do you 

Tracy Nelson-2 wrote:
> 
> What you're seeing is normal servlet/JSP processing.  After you restart
> Tomcat, the classloader has to load the servlet/JSP.  Once it has done
> this, the servlet/JSP is cached so it doesn't need to be reloaded.  The
> JSP files shouldn't be compiled again unless they change.  The server
> should check the last-modified time on the JSP when it receives a
> request, and compare that to the creation time of the compiled class,
> and recompile if necessary.
> 
> If you can (depending on how complex your application is), you might
> want to create a small script to access every page in your application,
> then run that as the last step in your Tomcat startup script.  It
> doesn't matter if the page is accessed "correctly" (i.e., passed any
> parameters it needs), it'll still be loaded and cached.
> 
> ---
> Tracy Nelson / Nelnet Business Solutions
> 402 / 617-9449
> 
> | -----Original Message-----
> | From: Frank Niedermann [mailto:fbn@thelogic.org]
> | Sent: Monday, 25 September, 2006 04:48
> | To: users@tomcat.apache.org
> | Subject: Re: Precompiled JSPs after Tomcat restart
> | 
> | 
> | I've found the .java and .class files in a new sample application.
> | 
> | I still don't understand if the compiled class files are used after
> | Tomcat restart or if the JSP files will get compiled again.
> | 
> | I'm asking because my application (Matrix from MatrixOne) is
> | very slow after restarting Tomcat. After visiting (and compiling?)
> | every JSP page it gets faster until next Tomcat restart.
> | 
> | Can anybody clarify or help me out with hints to documentation?
> | 
> | Thanks.
> | 
> | 
> | Michael Zoller wrote:
> | > Frank Niedermann wrote:
> | >> Hello,
> | >>
> | >> is it right that Tomcat stores all compiled JSP sites in
> | >> Tomcat5\work\Catalina\localhost\application\org\apache\jsp?
> | >>
> | > yes.
> | >> After a restart of Tomcat I still see all the .class files
> | >> in above mentioned directory, does that mean that these files
> | >> do not have to be compiled again at first access to them?
> | >>
> | > Educated guess: The servlets/jsp still have to be executed. Once
> they
> | > are loaded into memory they will execute faster because caching
> | > mechanisms (harddisk and OS) apply.
> | >
> | >
> | > Michael
> | >
> | >
> ---------------------------------------------------------------------
> | > 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
> | 
> | 
> | 
> | 
> | 
> | 
> | --
> | View this message in context: http://www.nabble.com/Precompiled-JSPs-
> | after-Tomcat-restart-tf2303735.html#a6483314
> | Sent from the Tomcat - User mailing list archive at Nabble.com.
> | 
> | 
> | ---------------------------------------------------------------------
> | 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Precompiled-JSPs-after-Tomcat-restart-tf2303735.html#a6500771
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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: Precompiled JSPs after Tomcat restart

Posted by Tracy Nelson <tn...@factsmgt.com>.
What you're seeing is normal servlet/JSP processing.  After you restart
Tomcat, the classloader has to load the servlet/JSP.  Once it has done
this, the servlet/JSP is cached so it doesn't need to be reloaded.  The
JSP files shouldn't be compiled again unless they change.  The server
should check the last-modified time on the JSP when it receives a
request, and compare that to the creation time of the compiled class,
and recompile if necessary.

If you can (depending on how complex your application is), you might
want to create a small script to access every page in your application,
then run that as the last step in your Tomcat startup script.  It
doesn't matter if the page is accessed "correctly" (i.e., passed any
parameters it needs), it'll still be loaded and cached.

---
Tracy Nelson / Nelnet Business Solutions
402 / 617-9449

| -----Original Message-----
| From: Frank Niedermann [mailto:fbn@thelogic.org]
| Sent: Monday, 25 September, 2006 04:48
| To: users@tomcat.apache.org
| Subject: Re: Precompiled JSPs after Tomcat restart
| 
| 
| I've found the .java and .class files in a new sample application.
| 
| I still don't understand if the compiled class files are used after
| Tomcat restart or if the JSP files will get compiled again.
| 
| I'm asking because my application (Matrix from MatrixOne) is
| very slow after restarting Tomcat. After visiting (and compiling?)
| every JSP page it gets faster until next Tomcat restart.
| 
| Can anybody clarify or help me out with hints to documentation?
| 
| Thanks.
| 
| 
| Michael Zoller wrote:
| > Frank Niedermann wrote:
| >> Hello,
| >>
| >> is it right that Tomcat stores all compiled JSP sites in
| >> Tomcat5\work\Catalina\localhost\application\org\apache\jsp?
| >>
| > yes.
| >> After a restart of Tomcat I still see all the .class files
| >> in above mentioned directory, does that mean that these files
| >> do not have to be compiled again at first access to them?
| >>
| > Educated guess: The servlets/jsp still have to be executed. Once
they
| > are loaded into memory they will execute faster because caching
| > mechanisms (harddisk and OS) apply.
| >
| >
| > Michael
| >
| >
---------------------------------------------------------------------
| > 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
| 
| 
| 
| 
| 
| 
| --
| View this message in context: http://www.nabble.com/Precompiled-JSPs-
| after-Tomcat-restart-tf2303735.html#a6483314
| Sent from the Tomcat - User mailing list archive at Nabble.com.
| 
| 
| ---------------------------------------------------------------------
| 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: Precompiled JSPs after Tomcat restart

Posted by Frank Niedermann <fb...@thelogic.org>.
I've found the .java and .class files in a new sample application.

I still don't understand if the compiled class files are used after
Tomcat restart or if the JSP files will get compiled again.

I'm asking because my application (Matrix from MatrixOne) is
very slow after restarting Tomcat. After visiting (and compiling?)
every JSP page it gets faster until next Tomcat restart.

Can anybody clarify or help me out with hints to documentation?

Thanks.


Michael Zoller wrote:
> Frank Niedermann wrote:
>> Hello,
>>
>> is it right that Tomcat stores all compiled JSP sites in
>> Tomcat5\work\Catalina\localhost\application\org\apache\jsp?
>>   
> yes.
>> After a restart of Tomcat I still see all the .class files
>> in above mentioned directory, does that mean that these files
>> do not have to be compiled again at first access to them?
>>   
> Educated guess: The servlets/jsp still have to be executed. Once they 
> are loaded into memory they will execute faster because caching 
> mechanisms (harddisk and OS) apply.
>
>
> Michael
>
> ---------------------------------------------------------------------
> 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






-- 
View this message in context: http://www.nabble.com/Precompiled-JSPs-after-Tomcat-restart-tf2303735.html#a6483314
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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: Precompiled JSPs after Tomcat restart

Posted by Frank Niedermann <fb...@thelogic.org>.
JSP lifecycle documentation tells me that there should be .java
files named _0002fpageName_jsp.java. I don't have such files
(no java files at all). 

I did a brand new Tomcat installation and executed one JSP
example but there is only a tldCache.ser file in work\Catalina\
localhost\jsp-examples.

Where are the compiled JSP files? How can I see if they get
cached or will Tomcat compile them every time or at restarts?

Regards,
  Frank

Michael Zoller wrote:
> Frank Niedermann wrote:
>> Hello,
>>
>> is it right that Tomcat stores all compiled JSP sites in
>> Tomcat5\work\Catalina\localhost\application\org\apache\jsp?
>>   
> yes.
>> After a restart of Tomcat I still see all the .class files
>> in above mentioned directory, does that mean that these files
>> do not have to be compiled again at first access to them?
>>   
> Educated guess: The servlets/jsp still have to be executed. Once they 
> are loaded into memory they will execute faster because caching 
> mechanisms (harddisk and OS) apply.
>
>
> Michael
>
> ---------------------------------------------------------------------
> 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




-- 
View this message in context: http://www.nabble.com/Precompiled-JSPs-after-Tomcat-restart-tf2303735.html#a6482813
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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: Precompiled JSPs after Tomcat restart

Posted by Santosh Puranshettiwar <sa...@wirkle.com>.
Google for "JSP lifycyle" to know more.

Santosh.
Michael Zoller wrote:
> Frank Niedermann wrote:
>> Hello,
>>
>> is it right that Tomcat stores all compiled JSP sites in
>> Tomcat5\work\Catalina\localhost\application\org\apache\jsp?
>>   
> yes.
>> After a restart of Tomcat I still see all the .class files
>> in above mentioned directory, does that mean that these files
>> do not have to be compiled again at first access to them?
>>   
> Educated guess: The servlets/jsp still have to be executed. Once they 
> are loaded into memory they will execute faster because caching 
> mechanisms (harddisk and OS) apply.
>
>
> Michael
>
> ---------------------------------------------------------------------
> 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: Precompiled JSPs after Tomcat restart

Posted by Michael Zoller <us...@zoller.co.at>.
Frank Niedermann wrote:
> Hello,
>
> is it right that Tomcat stores all compiled JSP sites in
> Tomcat5\work\Catalina\localhost\application\org\apache\jsp?
>   
yes.
> After a restart of Tomcat I still see all the .class files
> in above mentioned directory, does that mean that these files
> do not have to be compiled again at first access to them?
>   
Educated guess: The servlets/jsp still have to be executed. Once they 
are loaded into memory they will execute faster because caching 
mechanisms (harddisk and OS) apply.


Michael

---------------------------------------------------------------------
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