tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shreekanta Prasad <spras...@sapient.com>
Subject JSP pre compilation
Date Sun, 14 Sep 2008 12:52:44 GMT
Hi All,

          In our web application deployed as a war file in tomcat 5.5.25, after a new deployment
of war file, In order to open any link from home page first time we have click 3 times and
also it takes some time. This is due to JSP compilation happening at runtime. Is there anyway
to do JSP compilation at the time of server startup itself ?
At each time of deployment we are deleting the old directory of application from work folder
as well as webapps folder then copying new warfile to wepapps folder
then restarting the server. I tried <jasper2> task through ant script as explained in
tomcat documentation but it ends with some error(error related custom tag library),if  I delete
that jsp file which is giving error then it simply says build successful without creating
any class files !
  Any suggestion please give.

 Fallowing is the code snippet I tried

     <target name="jspc">

    <taskdef classname="org.apache.jasper.JspC" name="jasper2" >
      <classpath id="jspc.classpath">
        <pathelement location="${dir.tomcatHome}/../lib/tools.jar"/>
        <fileset dir="${dir.tomcatHome}/bin">
          <include name="*.jar"/>
        </fileset>
        <fileset dir="${dir.tomcatHome}/server/lib">
          <include name="*.jar"/>
        </fileset>
        <fileset dir="${dir.tomcatHome}/common/lib">
          <include name="*.jar"/>
        </fileset>
      </classpath>
    </taskdef>

            <jasper2
             validateXml="false"
             uriroot="${web.dir}"
             webXmlFragment="${web.dir}/WEB-INF/generated_web.xml"
             outputDir="${web.dir}/WEB-INF/src" />

                        </target>

                                     <target name="compile" depends="jspc">

    <mkdir dir="${web.dir}/WEB-INF/classes"/>
    <mkdir dir="${web.dir}/WEB-INF/lib"/>

    <javac destdir="${web.dir}/WEB-INF/classes"
           optimize="off"
           debug="on" failonerror="false"
           srcdir="${web.dir}/WEB-INF/views"
                   excludes="**/*.smap">
      <classpath>
        <pathelement location="${web.dir}/WEB-INF/classes"/>
        <fileset dir="${web.dir}/WEB-INF/lib">
          <include name="*.jar"/>
        </fileset>
        <pathelement location="${dir.tomcatHome}/common/classes"/>
        <fileset dir="${dir.tomcatHome}/common/lib">
          <include name="*.jar"/>
        </fileset>
        <pathelement location="${dir.tomcatHome}/shared/classes"/>
        <fileset dir="${dir.tomcatHome}/shared/lib">
          <include name="*.jar"/>
        </fileset>
        <fileset dir="${dir.tomcatHome}/bin">
          <include name="*.jar"/>
        </fileset>
      </classpath>
      <include name="views/*.jsp" />
      <exclude name="tags/**" />
               <exclude name="*/failure.jsp" />
    </javac>

  </target>


Thanks and Regards -
Shreekanta Prasad
Associate Technology| ¬ Sapient
Sapient Corporation Pvt. Ltd.0
#137, Whitefield Road, 6th Floor, 'Vayu' Block
Salarpuria GR Tech Park, Bangalore - 560066
Cell : +91.99 00 230 326
Office : +91.080.4104 7680
Email :sprasad4@sapient.com


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message