Jsp files which are compile time includes should not end in .jsp - but
something else. (Preferably .jspf)
renaming test2.jsp to test2.jspf will fix your precompilation issue.
Using jspf has the added advantage of also letting you know immediately
the files being used as compile time includes. If the jsp is also not
hidden in WEB-INF but on the document root - its also easier to protect
those files in case a malicious user could figure out such a fragment
exists and call it directly potentially bypassing validations or other
logic.
-Tim
Martin Lambert wrote:
Hi,
I'm having problems doing JSP pre-compilation using Tomcat's JSP
pre-compilation libraries and Ant. The problem is demonstrated by the following:
test.jsp:
<% String myVar = "Hello"; %>
<%@ include file="test2.jsp" %>
Some more text
test2.jsp
<H1>Goodbye</H1>
<%= myVar + "World" %>
<SNIP>
test.jsp loads correctly when accessed from Tomcat, however, when I use Ant
with the build.xml above and Tomcat's JSP compiler libraries I get:
D:\dev\myproject\build\web-test\org\apache\jsp\test2_jsp.java:43: cannot find
symbol
symbol : variable myVar
location: class org.apache.jsp.test2_jsp
out.print( myVar + "World" );
^
1 error
I have tested this using both Tomcat 5.5.15 and Tomcat 5.5.20.
When JspC completes there are 2 Java source files, test2_jsp.java which ties up with
test2.jsp's content (making reference to myVar but not declaring it) and test_jsp.java
which contains the combined content of test.jsp and test2.jsp. I've flagged that JspC
should compile the generated source files with the compile="true" attribute, I
discovered this through looking at the Javadocs.
My gut feel is that JspC should remove any Java source files that represent
JSPs that cannot be run standalone, e.g. test2.jsp, as its final step before
completing thus leaving only Java source files that can be compiled.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]