Hi Tim, Thanks for you reply, it fixed the problem!
A few points though for the Tomcat people: 1) http://java.sun.com/developer/technicalArticles/javaserverpages/code_convention/ states that: 'JSP fragments can use either .jsp or .jspf as a suffix' i.e. it should work for .jsp includes 2) .jsp includes work in the container so why not (apparently) for the Ant task they supply 3) As this is so useful, i.e. you can find out whether your applications JSPs work without the servlet container, the documentation of the Ant task should be better 4) I see the same problem with the Tomcat 4.1 libraries, so it appears to be a long standing problem. Don't get me wrong, I think this is a great extension to Ant that just needs some small wrinkles ironing out to become excellent. Thanks again, Martin. -----Original Message----- From: Tim Funk [mailto:[EMAIL PROTECTED] Sent: 25 January 2007 12:05 To: Tomcat Users List Subject: Re: JSP include issue when pre-compiling using Ant/Tomcat 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] --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]