luehe 2004/05/12 10:45:37 Modified: jasper2/src/share/org/apache/jasper/compiler Compiler.java ErrorDispatcher.java JspReader.java Mark.java Log: Fixed additional requirements from Bugzilla 28604: If compiling from JspC, the absolute (instead of context-relative) path of the JSP that caused the error is now printed (when compiling from JspServlet, we continue to print only the context-relative path of the JSP) Revision Changes Path 1.84 +15 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java Index: Compiler.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java,v retrieving revision 1.83 retrieving revision 1.84 diff -u -r1.83 -r1.84 --- Compiler.java 10 May 2004 16:34:59 -0000 1.83 +++ Compiler.java 12 May 2004 17:45:37 -0000 1.84 @@ -439,8 +439,22 @@ public void compile(boolean compileClass) throws FileNotFoundException, JasperException, Exception { + compile(compileClass, false); + } + + /** + * Compile the jsp file from the current engine context. As an side- + * effect, tag files that are referenced by this page are also compiled. + * + * @param compileClass If true, generate both .java and .class file + * If false, generate only .java file + * @param jspcMode true if invoked from JspC, false otherwise + */ + public void compile(boolean compileClass, boolean jspcMode) + throws FileNotFoundException, JasperException, Exception + { if (errDispatcher == null) { - this.errDispatcher = new ErrorDispatcher(); + this.errDispatcher = new ErrorDispatcher(jspcMode); } try { 1.17 +21 -2 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ErrorDispatcher.java Index: ErrorDispatcher.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ErrorDispatcher.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- ErrorDispatcher.java 17 Mar 2004 19:23:03 -0000 1.16 +++ ErrorDispatcher.java 12 May 2004 17:45:37 -0000 1.17 @@ -20,6 +20,7 @@ import java.io.StringReader; import java.util.ResourceBundle; import java.util.Vector; +import java.net.MalformedURLException; import org.apache.jasper.JasperException; import org.xml.sax.SAXException; @@ -46,12 +47,20 @@ // Custom error handler private ErrorHandler errHandler; + // Indicates whether the compilation was initiated by JspServlet or JspC + private boolean jspcMode = false; + + /* * Constructor. + * + * @param jspcMode true if compilation has been initiated by JspC, false + * otherwise */ - public ErrorDispatcher() { + public ErrorDispatcher(boolean jspcMode) { // XXX check web.xml for custom error handler errHandler = new DefaultErrorHandler(); + this.jspcMode = jspcMode; } /* @@ -340,7 +349,17 @@ // Get error location if (where != null) { - file = where.getFile(); + if (jspcMode) { + // Get the full URL of the resource that caused the error + try { + file = where.getURL().toString(); + } catch (MalformedURLException me) { + file = where.getFile(); + } + } else { + // Get the context-relative resource path + file = where.getFile(); + } line = where.getLineNumber(); column = where.getColumnNumber(); hasLocation = true; 1.20 +18 -0 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java Index: JspReader.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- JspReader.java 17 Mar 2004 19:23:03 -0000 1.19 +++ JspReader.java 12 May 2004 17:45:37 -0000 1.20 @@ -22,6 +22,8 @@ import java.io.InputStreamReader; import java.util.Vector; import java.util.jar.JarFile; +import java.net.URL; +import java.net.MalformedURLException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -402,6 +404,22 @@ void setSingleFile(boolean val) { singleFile = val; } + + + /** + * Gets the URL for the given path name. + * + * @param path Path name + * + * @return URL for the given path name. + * + * @exception MalformedURLException if the path name is not given in + * the correct form + */ + URL getResource(String path) throws MalformedURLException { + return context.getResource(path); + } + /** * Parse utils - Is current character a token delimiter ? 1.7 +14 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Mark.java Index: Mark.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Mark.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Mark.java 12 May 2004 00:26:53 -0000 1.6 +++ Mark.java 12 May 2004 17:45:37 -0000 1.7 @@ -16,6 +16,8 @@ package org.apache.jasper.compiler; import java.util.Stack; +import java.net.URL; +import java.net.MalformedURLException; /** * Mark represents a point in the JSP input. @@ -199,7 +201,18 @@ public String getFile() { return this.fileName; } - + + /** + * Gets the URL of the resource with which this Mark is associated + * + * @return URL of the resource with which this Mark is associated + * + * @exception MalformedURLException if the resource pathname is incorrect + */ + public URL getURL() throws MalformedURLException { + return reader.getResource(getFile()); + } + public String toShortString() { return "("+line+","+col+")"; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]