tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karasek-XID, Nicolas" <>
Subject RE: Pre-compiled JSPs?
Date Mon, 05 Sep 2005 11:04:13 GMT

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:

View raw message