I'm trying to pre-compile .jsp files just as a way to check for errors but the issue is that despite syntax errors in the .jsp file, the .class file is still successfully generated and no errors occur when precompiling using Ant.
I am using Tomcat's JSPC task.
<taskdef classname="org.apache.jasper.JspC" name="jasper" >
<classpath refid="myjars"/>
</taskdef>
<!--I also tried using it with compiler="org.eclipse.jdt.core.JDTCompilerAdapter"-->
<jasper
uriroot="WebContent"
outputDir="GenWebContent" />
However, if I deploy the application to Tomcat and go to the link (http://localhost/app/page.jsp?jsp_precompile=true) which also precompiles the JSP without running it, I actually do get an error regarding compiling the file.
org.apache.jasper.JasperException: Unable to compile class for JSP:
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:212)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:552)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:381)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:351)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:335)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:597)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:399)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
com.imedris.Utilities_Charset_Filter.doFilter(Utilities_Charset_Filter.java:25)
com.imedris.ClickjackFilter.doFilter(ClickjackFilter.java:31)
com.imedris.XssFilter.doFilter(XssFilter.java:182)
com.imedris.LocaleFilter.doFilter(LocaleFilter.java:24)
How can I get the same error I get by visiting the link as I do by building through Ant? Why does it successfully compile the JSP in Ant, despite the intentional syntax errors I introduced?
Any help or suggestions would be very appreciated. Thank you.