Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2005

Tip: Looking for answers? Try searching our database.

Tomcat, Precompile JSP Pages

Thread view: 
boanator@gmail.com - 30 Aug 2005 14:46 GMT
I have a website that consists of almost 200 JSP Pages.  The server
hosting this site is running Tomcat.  When Tomcat starts up, it kicks
off a servlet that will precompile all of the JSP pages.  This servlet
pings every single JSP page in the website.  When the JSP page is
pinged, it is forced to compile.  It takes nearly 2 hours to compile
all of the JSP pages using this servlet.  The server is a solaris 8
machine with a 333 MHz Processor and 128 Mb of RAM.

Here are my questions:
1) Should compiling 200 JSP Pages take 2 hours on this machine?
  (If not, then the time is being spent trying to run each JSP page
after it is compiled.)
2) Is the server machine too slow?
3) Is there another way to precompile JSP Pages without pinging them?

Any advice would be appreciated.  Thanks in advance.
Daniel Dyer - 30 Aug 2005 15:00 GMT
> I have a website that consists of almost 200 JSP Pages.  The server
> hosting this site is running Tomcat.  When Tomcat starts up, it kicks
[quoted text clipped - 12 lines]
>
> Any advice would be appreciated.  Thanks in advance.

I believe Tomcat includes an Ant task for pre-compilation of JSPs.

Alternatively, it might be worth investigating using Jikes for the  
compliation (if you are not using Java 5 features).  I've used it in the  
past (a couple of years ago) with JBoss/Tomcat to speed up JSP compilation  
considerably.

I also found this with a quick search on Google:

http://codinginparadise.org/weblog/2005/01/tomcat-jsp-precompilation-is-slow.html

Dan.

Signature

Daniel Dyer
http://www.dandyer.co.uk

Andrea Desole - 30 Aug 2005 15:02 GMT
> I have a website that consists of almost 200 JSP Pages.  The server
> hosting this site is running Tomcat.  When Tomcat starts up, it kicks
[quoted text clipped - 8 lines]
>    (If not, then the time is being spent trying to run each JSP page
> after it is compiled.)

mmmm.... 200 pages in 2 hours is 36 seconds per page. It looks a bit
slow, but it's possible. It also depends on how complex your pages are.
After all, your machine is not really the fastest possible

> 2) Is the server machine too slow?

that depends on what you have to do. If you use it at home, no. If you
use it to host the site of a big company with 10000 users a day, yes

> 3) Is there another way to precompile JSP Pages without pinging them?

Ant used to have a jspc task, which was using Tomcat's compiler. I
undesrtand from the documentation that you should use the specific task
that comes with Tomcat, if you are using a newer version.
Anyway, jspc is probably your answer
Tor Iver Wilhelmsen - 30 Aug 2005 15:26 GMT
> I have a website that consists of almost 200 JSP Pages.  The server
> hosting this site is running Tomcat.  When Tomcat starts up, it kicks
> off a servlet that will precompile all of the JSP pages.  This servlet
> pings every single JSP page in the website.

That's not the way to do a precompile - since you also trigger all the
business logic like session management etc.

Either predeclare the JSPs as servlets with load-on-startup in
web.xml, or Tomcat's JSP compilation Ant task.
Thomas Hawtin - 30 Aug 2005 18:26 GMT
> I have a website that consists of almost 200 JSP Pages.  The server
> hosting this site is running Tomcat.  When Tomcat starts up, it kicks
[quoted text clipped - 3 lines]
> all of the JSP pages using this servlet.  The server is a solaris 8
> machine with a 333 MHz Processor and 128 Mb of RAM.

Clearly something wrong. Are you sure it's a CPU problem? Is it
swapping? Or is it garbage collecting too much (use -Xms -Xmx to
increase heap size)?

Perhaps better than a servlet, but without precompiling, is to generate
a web.xml that loads all JSPs on start up. No need for anything fancy.
Even find and sed could do the generation.

Tom Hawtin
Roedy Green - 31 Aug 2005 01:52 GMT
>off a servlet that will precompile all of the JSP pages.

Does it do this even if the JSP pages have not changed?

I have not used Tomcat, but that behaviour seems unreasonable.

Has something changed which is legitimately triggering this orgy of
recompilation?

Are you clearing Tomcat's cache of java and class files forcing this
behaviour?

Compilation is slow because Javac needs a ton of ram.  Perhaps you can
buy a bit more for your beast to max it out.

I noticed that Ant-style compilation which loads a JVM once is much
much faster than invoking Javac for each batch.  Perhaps Tomcat has a
option to use Ant-style compilation.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Thomas Hawtin - 31 Aug 2005 11:28 GMT
> Compilation is slow because Javac needs a ton of ram.  Perhaps you can
> buy a bit more for your beast to max it out.

Recent version of Tomcat use the Eclipse JDT compiler by default.

> I noticed that Ant-style compilation which loads a JVM once is much
> much faster than invoking Javac for each batch.  Perhaps Tomcat has a
> option to use Ant-style compilation.

Last time I looked Tomcat's compiler configuration was "in an unfinished
state".

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.