You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Shweta Agarwal <sa...@digitalimpact.com> on 2004/11/03 17:58:54 UTC

Precompiling jsps in different directories does not produce right servlet mappings (jasper issue)

Hi all,
I have tried to google to find solution to my problem, but had no luck,
and thus I am writing to this list.
Also, I tried to search through archives and did not hit on any solution
yet.

I am using these two tasks (shown at the end of this email) in the ant
file with Tomcat version 4.1.31 for precompiling jsps.
I am using this because I want my jsps to be precompiled and also
because I want the web.xml file to 
be populated automatically with all the servlet mappings for the jsps.
 
It works fine for all the jsp files which are under the directory
"${basedir}/web" (one specified as uriroot for the jasper2 task).
But I have a jsp in directory as file
${basedir}/web/level1/level2/bookreg_error.jsp.  
For this jsp file, the class is built in the right hierarchy, 
the class file is in location
${basedir}/war/WEB-INF/classes/${app.name}/level1/level2/bookreg_error.c
lass. (which is what i expected)
But the servlet mapping is still as follows (which I did not expect) in
the generated_web.xml file.

 <servlet>
  <servlet-name>sic.bookreg_error_jsp</servlet-name>
  <servlet-class>sic.bookreg_error_jsp</servlet-class>
 </servlet>
 
<servlet-mapping>
  <servlet-name>sic.bookreg_error_jsp</servlet-name>
  <url-pattern>/bookreg_error.jsp</url-pattern>
 </servlet-mapping>

There is actually no class called sic.bookreg_error_jsp but only class
is sic.level1.level2.bookreg_error_jsp. 
Instead I was expecting the generated_web.xml file to have following
entry.
 
 <servlet>
  <servlet-name>sic.level1.level2.bookreg_error_jsp</servlet-name>
  <servlet-class>sic.level1.level2.bookreg_error_jsp</servlet-class>
 </servlet>
 
<servlet-mapping>
  <servlet-name>sic.level1.level2.bookreg_error_jsp</servlet-name>
  <url-pattern>/level1/level2/bookreg_error.jsp</url-pattern>
 </servlet-mapping>
 
Can somebody please help me here.  Normally, I think jsps should all be
in one directory.
Does this org.apache.jasper.JspC assume that all jsps should be only in
the uriroot level to create the servlet mappings.
Thanks in advance...
Shweta
 
----------------------------------------
XML snippet from my ant build file..
---------------------------------------
 
 
 <target name="jspc"> 
 
    <taskdef classname="org.apache.jasper.JspC" name="jasper2" > 
      <classpath id="jspc.classpath"> 
        <pathelement location="${java.home}/../lib/tools.jar"/> 
        <fileset dir="${tomcat.home}/server/lib"> 
          <include name="*.jar"/> 
        </fileset> 
        <fileset dir="${tomcat.home}/common/lib"> 
          <include name="*.jar"/> 
        </fileset> 
  <pathelement location="${basedir}/WEB-INF/classes"/>  
      </classpath> 
    </taskdef> 
 
    <jasper2 
             validateXml="false" 
    package="${app.name}"
             uriroot="${basedir}/web" 
             webXmlFragment="${basedir}/WEB-INF/generated_web.xml" 
             outputDir="${basedir}/jsp_generated" /> 
 
 <loadfile property="generated_web.xml" 
          srcFile="${basedir}/WEB-INF/generated_web.xml" /> 
 
 <replace file="${basedir}/WEB-INF/web.xml" value="${generated_web.xml}"

         token="&lt;!-- GEN_JSP_TOKEN --&gt;"/> 
   
 <delete file="${basedir}/WEB-INF/generated_web.xml" />
 
<javac srcdir="${basedir}/jsp_generated"
destdir="${basedir}/war/WEB-INF/classes">
            <include name="**/*.java"/>
            <classpath refid="classpath"/>
 </javac>
 
  </target> 
 
 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org