tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Burman" <>
Subject RE: Pre-compiled JSPs?
Date Tue, 06 Sep 2005 11:13:04 GMT
Hi Nicolas,

Thanks for your reply, I really appreciate your help. I'm not sure I
fully understand your solution. I see now that the webXmlFragment
provides a convenient way to generate the XML needed for the Servlets
but that have bizarre names.

Let's say I have a jsp:

Running Jasper at it provides a java file:

Then the Servlet definition would be:

The way to reference my JSP used to be:

What would the new reference be?

Have I missed something obvious?

Thanks for your help!

-----Original Message-----
From: Karasek-XID, Nicolas [] 
Sent: 05 September 2005 12:04
To: Tomcat Users List
Subject: RE: Pre-compiled JSPs?


You need to insert in your web.xml the reference to the precompiled
servlets. Jasper can generate a web.xml fragment when turning JSP into
servlets. You can then insert the fragment into your web.xml
Something like this with ant:

<!-- turn jsp into servlets -->
<jasper2 verbose="0"
	outputDir="${webapp.path}/WEB-INF/src" />

<!-- Load the precompiled snippet into a property -->
<loadfile property="precompiled"
	srcFile=" generated-web.xml"
	encoding="ISO-8859-1" />

<!-- Now replace the web.xml with a predefined snippet -->
<!-- copy web.xml -->
<replace file="web.xml" value="${precompiled}">
<replacetoken>&lt;!-- jsp-servlets will be inserted here - do not remove
this line --&gt;</replacetoken>

-----Original Message-----
From: Richard Burman [] 
Sent: lundi 5 septembre 2005 12:44
To: Tomcat Users List
Subject: Pre-compiled JSPs?

Hi everyone,

I have a fairly elaborate problem but hope that some people out there
can help with it.

I am trying to take a large webapp and create pre-compiled JSPs. We
already compile the java into class files, then package in JARs, then
finally a WAR, but we would like to be able to package the JSPs into a
neat package, too.

The first hurdle was trying to circumvent the issue of when JSPs include
each other and a bean is used in both JSPs but can only be declared once
when the JSPs are combined. Thus, you have to leave out the bean
declaration in the second JSP but then it will not compile on it's own
because it has no knowledge of the bean. Fortunately, in the recent
Tomcat releases, it's possible to use the flag
'errorOnUseBeanInvalidClassAttribute' to ignore this problem.

Once the JSPs have been turned into Java classes by Jasper2, it's not
too hard to compile them into class files. But how do you deploy these
compiled classes so that Tomcat knows to use them? If the Whatever.jsp
file doesn't exist, how does Tomcat know where or how to find the
compiled JSP file? Should I put them in a JAR and deploy somewhere? Do I
need to change the web.xml or similar to inform Tomcat about this?

If anyone has any suggestions, advice or solutions to this, I would be
eternally grateful! :)


To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message