Hello,
I use the following ant target to compile / and generate jsp definitions in
the web.xml file
<!-- ==================== compile.jsp =================================== -->
<!--
  The "compile.jsp" target generates from jsp files by means of Jasper2 java source 
files
  into the project source directory. It also generates a web_jsp.xml file that 
contains the
  related entries for the web.xml file.

-->
  
        <target name="compile.jsp" description="compiles jsp files to java sources">
                 <taskdef classname="org.apache.jasper.JspC" name="jasper2" >
         <classpath id="jspc.classpath">
         <pathelement location="${java.home}/../lib/tools.jar"/>
         <fileset dir="${catalina.home}/server/lib">
            <include name="*.jar"/>
         </fileset>
         <fileset dir="${catalina.home}/common/lib">
            <include name="*.jar"/>
         </fileset>
        </classpath>
        </taskdef>
                
         <jasper2
                verbose="1"
             validateXml="true"
             uriroot="${web.home}"
             webXmlFragment="${web.home}/WEB-INF/web_jsp.xml"
             outputDir="${basedir}/src" />

    </target>

This ant target generates java sources into a directory src. Afterwards those java 
classes are compiled
using the normal way all my project classes are compiled (I use Eclipse as IDE). Then 
I supply them inside
my WAR file. Also you will need the generated webXmlFragement (called web_jsp.xml). 
The compiled jsp's are
indeed just another servlets. Here is a snippet how the web_jsp.xml fragment may look 
for a jsp called footer.jsp
        <servlet>
                <servlet-name>jsp.footer_jsp</servlet-name>
                <servlet-class>jsp.footer_jsp</servlet-class>
        </servlet>
        <servlet-mapping>
                <servlet-name>jsp.footer_jsp</servlet-name>
                <url-pattern>/jsp/footer.jsp</url-pattern>
        </servlet-mapping>

In order to make my "normal" web.xml file more readable I just included the 
web_jsp.xml as so-called external
entity in my web.xml file. Here is an example for that.
<!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 
'http://java.sun.com/j2ee/dtds/web-app_2_3.dtd' [
        <!ENTITY web_jsp SYSTEM "web_jsp.xml"> 
]>
<display-name>DemoAppl</display-name>

        <servlet>
                <servlet-name>demo</servlet-name>
                <description>Simple Test Servlet to test the Jackpot Custom 
tags</description>
                <servlet-class>servlet.JspSimpleServlet</servlet-class>
                <init-param>
                        <param-name>simpleservlet.jsp.directory</param-name>
                        <param-value>/jsp</param-value>
                </init-param>
        </servlet>
        
        <!--
                Here we import the webinc.xml files that contains servlets for the
                jsp 
        -->
                &web_jsp;
        <!--
                Here comes my normal servlet mapping
        -->

        <servlet-mapping>
                <servlet-name>demo</servlet-name>
                <url-pattern>*.do</url-pattern>
        </servlet-mapping>



So when accessing my jsp page "jsp/footer.jsp" than the servlet jsp.footer_jsp is 
invoked and no compilation
takes place.

Regards
Karin


-----Original Message-----
From: Duncan Frostick [mailto:[EMAIL PROTECTED]
Sent: Dienstag, 9. September 2003 12:29
To: Tomcat Users List
Subject: JSP Compilation - saving compiled JSPs to disk howto?


(If this is received twice I apologise)

Hi all,

I'm hoping this is a simple question that only needs one config change, 
but I don't know. I need to configure tomcat so that when a JSP is 
compiled upon first request, the actual compiled file is saved to disk 
permanently and used by tomcat from the disk rather than stored and run 
only from memory. The reason this is needed is so that after a tomcat 
restart (which is needed quite regularly), all the JSPs don't need to be 
recompiled, which takes a long time on our large application. Of course, 
if the JSP source has changed, then it would need to recompile, but 
otherwise I'd like it to use a disk copy of the compiled JSP, saving the 
server recompiling upon a restart, thus saving our users a long time of 
waiting for the server to become responsive again.

Any help much appreciated,

Duncan Frostick


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to