You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ki...@apache.org on 2001/10/03 23:48:31 UTC

cvs commit: jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/resources messages.properties messages_ja.properties

kinman      01/10/03 14:48:31

  Modified:    jasper/src/share/org/apache/jasper/compiler
                        JspParseEventListener.java
               jasper/src/share/org/apache/jasper/servlet JspServlet.java
               jasper/src/share/org/apache/jasper/resources
                        messages.properties messages_ja.properties
  Added:       jasper/src/share/org/apache/jasper JasperError.java
  Log:
  PR: 3667, 3669
  All messages from all validators in tag libraries are now displayed,
  without throwing an exception that causes the stack trace to be printed.
  
  Revision  Changes    Path
  1.1                  jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JasperError.java
  
  Index: 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 apache@apache.org.
   *
   * 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);
      }
  }
  
  
  
  1.34      +21 -10    jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspParseEventListener.java
  
  Index: JspParseEventListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspParseEventListener.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- JspParseEventListener.java	2001/07/25 01:08:13	1.33
  +++ JspParseEventListener.java	2001/10/03 21:48:30	1.34
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspParseEventListener.java,v 1.33 2001/07/25 01:08:13 craigmcc Exp $
  - * $Revision: 1.33 $
  - * $Date: 2001/07/25 01:08:13 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspParseEventListener.java,v 1.34 2001/10/03 21:48:30 kinman Exp $
  + * $Revision: 1.34 $
  + * $Date: 2001/10/03 21:48:30 $
    *
    * ====================================================================
    *
  @@ -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());
       }
   
       /**
  
  
  
  1.22      +3 -0      jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/servlet/JspServlet.java
  
  Index: JspServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/servlet/JspServlet.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- JspServlet.java	2001/08/25 00:01:56	1.21
  +++ JspServlet.java	2001/10/03 21:48:30	1.22
  @@ -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) {
  
  
  
  1.21      +2 -2      jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/resources/messages.properties
  
  Index: messages.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/resources/messages.properties,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- messages.properties	2001/09/07 17:57:46	1.20
  +++ messages.properties	2001/10/03 21:48:30	1.21
  @@ -1,4 +1,4 @@
  -# $Id: messages.properties,v 1.20 2001/09/07 17:57:46 craigmcc Exp $
  +# $Id: messages.properties,v 1.21 2001/10/03 21:48:30 kinman Exp $
   #
   # Default localized string information
   # Localized this the Default Locale as is en_US
  @@ -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=Validation error messages from tag library {0}
   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}
  
  
  
  1.3       +2 -2      jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/resources/messages_ja.properties
  
  Index: messages_ja.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/resources/messages_ja.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- messages_ja.properties	2001/09/17 23:14:43	1.2
  +++ messages_ja.properties	2001/10/03 21:48:30	1.3
  @@ -1,4 +1,4 @@
  -# $Id: messages_ja.properties,v 1.2 2001/09/17 23:14:43 craigmcc Exp $
  +# $Id: messages_ja.properties,v 1.3 2001/10/03 21:48:30 kinman Exp $
   #
   # Default localized string information
   # Localized this the Default Locale as is ja_JP
  @@ -209,7 +209,7 @@
   jspc.error.emptyWebApp=-webapp\u30aa\u30d7\u30b7\u30e7\u30f3\u306b\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u5f15\u6570\u304c\u5fc5\u8981\u3067\u3059
   jsp.error.library.invalid=\u30e9\u30a4\u30d6\u30e9\u30ea{0}\u306b\u5f93\u3046\u3068JSP\u30da\u30fc\u30b8\u306f\u7121\u52b9\u3067\u3059: {1}
   jsp.warning.tlvclass.is.null=TagLibraryValidator\u30af\u30e9\u30b9{0}\u3092\u30ed\u30fc\u30c9\u3067\u304d\u307e\u305b\u3093: {1}
  -jsp.error.taglibraryvalidator.invalidpage={0}\u30e9\u30a4\u30d6\u30e9\u30ea\u4e2d\u306eTagLibraryValidator - \u7121\u52b9\u306a\u30da\u30fc\u30b8: {1}
  +jsp.error.taglibraryvalidator.invalidpage=
   jsp.parser.sax.propertynotsupported=SAX\u30d7\u30ed\u30d1\u30c6\u30a3\u304c\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u307e\u305b\u3093: {0}
   jsp.parser.sax.propertynotrecognized=SAX\u30d7\u30ed\u30d1\u30c6\u30a3\u304c\u8a8d\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}