Tomcat, Precompile JSP Pages

Discussion in 'Java' started by boanator@gmail.com, Aug 30, 2005.

  1. Guest

    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.
    , Aug 30, 2005
    #1
    1. Advertising

  2. Daniel Dyer Guest

    On Tue, 30 Aug 2005 14:46:50 +0100, <> wrote:

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


    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.

    --
    Daniel Dyer
    http://www.dandyer.co.uk
    Daniel Dyer, Aug 30, 2005
    #2
    1. Advertising

  3. wrote:
    > 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.)


    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
    Andrea Desole, Aug 30, 2005
    #3
  4. writes:

    > 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.
    Tor Iver Wilhelmsen, Aug 30, 2005
    #4
  5. wrote:
    > 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.


    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
    Thomas Hawtin, Aug 30, 2005
    #5
  6. Roedy Green Guest

    On 30 Aug 2005 06:46:50 -0700, wrote or quoted :

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

    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
    Roedy Green, Aug 31, 2005
    #6
  7. Roedy Green wrote:
    >
    > 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
    --
    Unemployed English Java programmer
    http://jroller.com/page/tackline/
    Thomas Hawtin, Aug 31, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vijay
    Replies:
    0
    Views:
    3,317
    Vijay
    Mar 5, 2005
  2. cool2005

    precompile jsp

    cool2005, Mar 15, 2006, in forum: Java
    Replies:
    0
    Views:
    528
    cool2005
    Mar 15, 2006
  3. Replies:
    0
    Views:
    1,805
  4. tiewknvc9
    Replies:
    4
    Views:
    1,738
  5. harryos

    precompile jsp in tomcat 6

    harryos, Nov 27, 2008, in forum: Java
    Replies:
    3
    Views:
    3,880
Loading...

Share This Page