This patch addresses the problems raised in bug#3367 and #3368. All the messages from all validators are now displayed, without the stack trace. misto% pwd /home/kchung/tomcat/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper misto% cat JasperError.java /* * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.jasper; /** * Errors generated by the JSP engine. It differs from JasperException in * that it does not print stack trace. * * @author Kin-man Chung */ public class JasperError extends org.apache.jasper.JasperException { public JasperError(String reason) { super(reason); } } misto% runsocks cvs diff -u compiler/JspParseEventListener.java Index: compiler/JspParseEventListener.java =================================================================== RCS file: /home/cvspublic/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/J spParseEventListener.java,v retrieving revision 1.33 diff -u -r1.33 JspParseEventListener.java --- compiler/JspParseEventListener.java 2001/07/25 01:08:13 1.33 +++ compiler/JspParseEventListener.java 2001/09/26 01:49:02 @@ -78,10 +78,10 @@ import javax.servlet.jsp.tagext.TagLibraryInfo; import javax.servlet.jsp.tagext.ValidationMessage; +import org.apache.jasper.JasperError; import org.apache.jasper.JasperException; import org.apache.jasper.Constants; import org.apache.jasper.JspCompilationContext; - import org.apache.jasper.logging.Logger; import org.xml.sax.Attributes; @@ -1114,7 +1114,9 @@ * libraries used by the document. */ public void validate() throws JasperException { + StringBuffer errMessage = new StringBuffer(); Enumeration enum = libraries.getTagLibInfos(); + boolean hasErrors = false; while (enum.hasMoreElements()) { TagLibraryInfo tli = (TagLibraryInfo)enum.nextElement(); //@@@ remove cast when TagLibraryInfo is fixed in spec @@ -1122,14 +1124,23 @@ ValidationMessage[] errors = ((TagLibraryInfoImpl)tli).validate(xo.getPageData()); if ((errors != null) && (errors.length != 0)) { - // for now just report the first error! - String msg = errors[0].getMessage(); - throw new JasperException( - Constants.getString( - "jsp.error.taglibraryvalidator.invalidpage", - new Object[]{tli.getShortName(), msg})); + hasErrors = true; + errMessage.append("<h3>"); + errMessage.append(Constants.getString( + "jsp.error.taglibraryvalidator.invalidpage", + new Object[]{tli.getShortName()})); + errMessage.append("</h3>"); + for (int i = 0; i < errors.length; i++) { + errMessage.append("<p>"); + errMessage.append(errors[i].getId()); + errMessage.append(": "); + errMessage.append(errors[i].getMessage()); + errMessage.append("</p>"); + } } } + if (hasErrors) + throw new JasperError(errMessage.toString()); } /** misto% runsocks cvs diff -u servlet/JspServlet.java Index: servlet/JspServlet.java =================================================================== RCS file: /home/cvspublic/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/servlet/Js pServlet.java,v retrieving revision 1.21 diff -u -r1.21 JspServlet.java --- servlet/JspServlet.java 2001/08/25 00:01:56 1.21 +++ servlet/JspServlet.java 2001/09/26 01:49:19 @@ -83,6 +83,7 @@ import java.security.Policy; import java.security.PrivilegedAction; +import org.apache.jasper.JasperError; import org.apache.jasper.JasperException; import org.apache.jasper.Constants; import org.apache.jasper.Options; @@ -473,6 +474,8 @@ serviceJspFile(request, response, jspUri, null, precompile); } catch (RuntimeException e) { throw e; + } catch (JasperError ex) { + response.getWriter().print(ex.getMessage()); } catch (ServletException e) { throw e; } catch (IOException e) { misto% runsocks cvs diff -u resources/messages.properties Index: resources/messages.properties =================================================================== RCS file: /home/cvspublic/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/resources/ messages.properties,v retrieving revision 1.20 diff -u -r1.20 messages.properties --- resources/messages.properties 2001/09/07 17:57:46 1.20 +++ resources/messages.properties 2001/09/26 01:49:37 @@ -213,7 +213,7 @@ jspc.error.emptyWebApp=-webapp requires a trailing file argument jsp.error.library.invalid=JSP page is invalid according to library {0}: {1} jsp.warning.tlvclass.is.null=Could not load TagLibraryValidator class {0}: {1} -jsp.error.taglibraryvalidator.invalidpage=TagLibraryValidator in {0} library - invalid page: {1} +jsp.error.taglibraryvalidator.invalidpage=Validator messages from {0} tag library - invalid page jsp.parser.sax.propertynotsupported=SAX property not supported: {0} jsp.parser.sax.propertynotrecognized=SAX property not recognized: {0} jsp.parser.sax.featurenotsupported=SAX feature not supported: {0} misto% runsocks cvs diff -u resources/messages_ja.properties Index: resources/messages_ja.properties =================================================================== RCS file: /home/cvspublic/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/resources/ messages_ja.properties,v retrieving revision 1.2 diff -u -r1.2 messages_ja.properties --- resources/messages_ja.properties 2001/09/17 23:14:43 1.2 +++ resources/messages_ja.properties 2001/09/26 01:49:56 @@ -209,7 +209,7 @@ jspc.error.emptyWebApp=-webapp\u30aa\u30d7\u30b7\u30e7\u30f3\u306b\u306f\u3001\u 30d5\u30a1\u30a4\u30eb\u5f15\u6570\u304c\u5fc5\u8981\u3067\u3059 jsp.error.library.invalid=\u30e9\u30a4\u30d6\u30e9\u30ea{0}\u306b\u5f93\u3046\u3 068JSP\u30da\u30fc\u30b8\u306f\u7121\u52b9\u3067\u3059: {1} jsp.warning.tlvclass.is.null=TagLibraryValidator\u30af\u30e9\u30b9{0}\u3092\u30e d\u30fc\u30c9\u3067\u304d\u307e\u305b\u3093: {1} -jsp.error.taglibraryvalidator.invalidpage={0}\u30e9\u30a4\u30d6\u30e9\u30ea\u4e 2d\u306eTagLibraryValidator - \u7121\u52b9\u306a\u30da\u30fc\u30b8: {1} +jsp.error.taglibraryvalidator.invalidpage= jsp.parser.sax.propertynotsupported=SAX\u30d7\u30ed\u30d1\u30c6\u30a3\u304c\u30b 5\u30dd\u30fc\u30c8\u3055\u308c\u307e\u305b\u3093: {0} jsp.parser.sax.propertynotrecognized=SAX\u30d7\u30ed\u30d1\u30c6\u30a3\u304c\u8a 8d\u8b58\u3055\u308c\u307e\u305b\u3093: {0} jsp.parser.sax.featurenotsupported=SAX\u30d5\u30a3\u30fc\u30c1\u30e3\u304c\u30b5 \u30dd\u30fc\u30c8\u3055\u308c\u307e\u305b\u3093: {0}