You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Uri Cohen <Ur...@proficiency.com> on 2001/07/12 19:06:48 UTC

Precompiled JSPs

I precompiled all my JSPs in the application, using jspc. Most pages
work OK, but there are some pages which don't. For some reason, when
loading these pages the session is lost, causing many errors. I solved
the problem by sending the request parameter JSESSIONID when calling
these pages. 
These pages worked fine as regular JSPs, and this symptom only occures
when I use them as servlets. 
Has anyone encountered such a problem? 

Re: Precompiled JSPs

Posted by Oskar Zinger <os...@micromuse.com>.
Hi Uri,
You have to compile your JSPs with -webxml and -webapp options.  This
option will create a web.xml file with all the required servlet mapping
and everything will work fine.

I ran such command:
jspc.sh -p <package name> -dd <directory there to output translate java
files> -webxml <path where to store a web.xml file (i.e. /temp/web.xml)>
-webapp <directory of your webapp where all the JSPs reside>

After the web.xml file is produced you have incorporate it with your
tomcat original web.xml file.

Or you could create a servlet mapping for your jsps manually.  In the
following way:
<servlet>
   <servlet-name>com.somecompany.pacakge.SomeJsp</servlet-name>
   <servlet-class>com.somecompany.pacakge.SomeJsp</servlet-class>
<servlet>
.
.  you need to put all servlet tags first (for each jsp)
.  then servlet-mapping tags go (for each jsp)
.
<servlet-mapping>
   <servlet-name>com.somecompany.pacakge.SomeJsp</servlet-name>
   <url-pattern>/SomeJsp.jsp</url-pattern>
</servlet-mapping>

This way you do not need to change urls in your original JSPs to class
names, you can just use the same urls in your JSPs and pre-compiled JSPs.

Hope this helps,
Oskar

Uri Cohen wrote:

> I precompiled all my JSPs in the application, using jspc. Most pages
> work OK, but there are some pages which don't. For some reason, when
> loading these pages the session is lost, causing many errors. I solved
> the problem by sending the request parameter JSESSIONID when calling
> these pages.
> These pages worked fine as regular JSPs, and this symptom only occures
> when I use them as servlets.
> Has anyone encountered such a problem?