7 Replies Latest reply on Aug 21, 2003 4:33 AM by frodeh

    How to prevent compiled JSP classes to be deleted when JBoss

    timwang

      Hi,
      I have a question bothered me for a long time.
      Because each time when jboss started , the jsp files must be recompiled when first time access them . That would cost too much time and our user have to wait.
      How to prevent compiled JSP classes to be deleted when JBoss is restarted .
      I think there should have some way .

        • 1. Re: How to prevent compiled JSP classes to be deleted when J
          jonlee

          It can be done on a per web application basis for Jetty. Create a jetty-web.xml in the WEB-INF directory of your WAR.
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure 1.2//EN" "http://jetty.mortbay.org/configure_1_2.dtd">


          jsp

          scratchdir
          /jetty/MyCompJspDir





          This places the compile results in /jetty/MyCompJspDir and effectively beyond the control of JBoss when it performs its shutdown clean up of temporary directories.

          Hope that helps.

          • 2. Re: How to prevent compiled JSP classes to be deleted when J
            timwang

            succeeded, thank you

            • 3. Re: How to prevent compiled JSP classes to be deleted when J

              How can the same be done when using Tomcat ??

              • 4. Re: How to prevent compiled JSP classes to be deleted when J
                jonlee

                Unfortunately, I have not seen a similar capability in Tomcat 4.x. You are able to achieve this in Jetty because there is a custom override setting provided by Jetty.

                There are no Tomcat configurations that JBoss doesn't track that I have found. I've tried explicit CatalinaHome definitions but JBoss still wipes the generated Java and class files. Perhaps this will be/has been addressed in later JBoss versions.

                I haven't experimented with defining the scratchdir for the Jasper definition in web.xml. This will probably have side-effects such as clashes with different contexts with the same JSP names in the application.

                Someone else may have found a means of doing this. The other option is to precompile or to generate servlets from the JSPs and bundle the results into the web application.

                • 5. Re: How to prevent compiled JSP classes to be deleted when J

                  Then the switch from Jetty to Tomcat really is a degrade of Jboss ....

                  This feature is really useful under development where the app is restartet quite often because of some servlet-changes.

                  Another change from Jetty to Tomcat I have noticed, is the way the dispatcher handles redirects to JSP's. This makes it neccesary to recode all servlets, and to have two seperate sets of applications to work on either Jetty or Tomcat...

                  (Jetty makes a relative referece from the requestes servlet while Tomcat makes reference to root..)

                  Why did Jboss change it's default web-container ???

                  • 6. Re: How to prevent compiled JSP classes to be deleted when J

                    One thing that can be done, is to delete the 'jsp' servlet from the default web.xml, and put one in every app that needs jsp's. Then set the scratch-dir for the servlet to a ocation out of Jboss' control.

                    • 7. Re: How to prevent compiled JSP classes to be deleted when J

                      You don't have to delete the default one either...

                      I have tested a bit more, and found one easier way..

                      In the WEB.XML for your app, you create a servlet like this :


                      <servlet-name>jsp2</servlet-name>
                      <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
                      <init-param>
                      <param-name>logVerbosityLevel</param-name>
                      <param-value>WARNING</param-value>
                      </init-param>
                      <init-param>
                      <param-name>scratchdir</param-name>
                      <param-value>(Your path)</param-value>
                      </init-param>
                      <load-on-startup>3</load-on-startup>



                      and map it like this :

                      <servlet-mapping>
                      <servlet-name>jsp2</servlet-name>
                      <url-pattern>*.jsp</url-pattern>
                      </servlet-mapping>


                      Note that you cannot name it JSP, since this servlet-name is already taken, but you can specify the same mapping, and this mapping will override the default one...