tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kin...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources messages.properties
Date Fri, 23 Aug 2002 23:56:54 GMT
kinman      2002/08/23 16:56:54

  Modified:    jasper2/src/share/org/apache/jasper/compiler Generator.java
                        JspUtil.java Node.java Parser.java Validator.java
               jasper2/src/share/org/apache/jasper/resources
                        messages.properties
  Log:
  Various changes related <jsp:attribute>
  
    - When attribute specifies a non rtexpr, its body must be a TemplateTextBody,
      whihch means scriptlets, EL and standard actions are disallowed.
    - Make sure that jsp:attribute is allowed in all standard and custom actions
    - Check that the same attribute does not appear in both the attribte list
      and jsp:attribute.
    - Modified Validator and Generator to pick up attribute value from either
      the attribute list or jsp:attribute.
  
  Revision  Changes    Path
  1.78      +36 -36    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java
  
  Index: Generator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
  retrieving revision 1.77
  retrieving revision 1.78
  diff -u -r1.77 -r1.78
  --- Generator.java	22 Aug 2002 21:31:28 -0000	1.77
  +++ Generator.java	23 Aug 2002 23:56:53 -0000	1.78
  @@ -775,7 +775,7 @@
   		    out.print(" + ");
   		    out.print(separator);
   		    out.print(" + \"");
  -		    out.print(n.getAttributeValue("name"));
  +		    out.print(n.getTextAttribute("name"));
   		    out.print("=\" + ");
   		    out.print(attributeValue(n.getValue(), true, String.class,
                           "null" ));
  @@ -828,7 +828,7 @@
   
   	public void visit(Node.IncludeAction n) throws JasperException {
   
  -	    String flush = n.getAttributeValue("flush");
  +	    String flush = n.getTextAttribute("flush");
   	    Node.JspAttribute page = n.getPage();
   
   	    boolean isFlush = false;	// default to false;
  @@ -966,8 +966,8 @@
   	}
   
   	public void visit(Node.GetProperty n) throws JasperException {
  -	    String name = n.getAttributeValue("name");
  -	    String property = n.getAttributeValue("property");
  +	    String name = n.getTextAttribute("name");
  +	    String property = n.getTextAttribute("property");
   
   	    n.setBeginJavaLine(out.getJavaLine());
   
  @@ -995,9 +995,9 @@
           }
   
           public void visit(Node.SetProperty n) throws JasperException {
  -	    String name = n.getAttributeValue("name");
  -	    String property = n.getAttributeValue("property");
  -	    String param = n.getAttributeValue("param");
  +	    String name = n.getTextAttribute("name");
  +	    String property = n.getTextAttribute("property");
  +	    String param = n.getTextAttribute("param");
   	    Node.JspAttribute value = n.getValue();
   
   	    n.setBeginJavaLine(out.getJavaLine());
  @@ -1059,10 +1059,10 @@
   
           public void visit(Node.UseBean n) throws JasperException {
   
  -	    String name = n.getAttributeValue ("id");
  -	    String scope = n.getAttributeValue ("scope");
  -	    String klass = n.getAttributeValue ("class");
  -	    String type = n.getAttributeValue ("type");
  +	    String name = n.getTextAttribute ("id");
  +	    String scope = n.getTextAttribute ("scope");
  +	    String klass = n.getTextAttribute ("class");
  +	    String type = n.getTextAttribute ("type");
   	    Node.JspAttribute beanName = n.getBeanName();
   
   	    if (type == null)	// if unspecified, use class as type of bean 
  @@ -1219,7 +1219,7 @@
   
                   public void visit(Node.ParamAction n) throws JasperException {
   
  -		    String name = n.getAttributeValue("name");
  +		    String name = n.getTextAttribute("name");
   		    if (name.equalsIgnoreCase("object"))
   			name = "java_object";
   		    else if (name.equalsIgnoreCase ("type"))
  @@ -1254,19 +1254,19 @@
   		}
   	    }
   
  -	    String type = n.getAttributeValue("type");
  -	    String code = n.getAttributeValue("code");
  -	    String name = n.getAttributeValue("name");
  +	    String type = n.getTextAttribute("type");
  +	    String code = n.getTextAttribute("code");
  +	    String name = n.getTextAttribute("name");
   	    Node.JspAttribute height = n.getHeight();
   	    Node.JspAttribute width = n.getWidth();
  -	    String hspace = n.getAttributeValue("hspace");
  -	    String vspace = n.getAttributeValue("vspace");
  -	    String align = n.getAttributeValue("align");
  -	    String iepluginurl = n.getAttributeValue("iepluginurl");
  -	    String nspluginurl = n.getAttributeValue("nspluginurl");
  -	    String codebase = n.getAttributeValue("codebase");
  -	    String archive = n.getAttributeValue("archive");
  -	    String jreversion = n.getAttributeValue("jreversion");
  +	    String hspace = n.getTextAttribute("hspace");
  +	    String vspace = n.getTextAttribute("vspace");
  +	    String align = n.getTextAttribute("align");
  +	    String iepluginurl = n.getTextAttribute("iepluginurl");
  +	    String nspluginurl = n.getTextAttribute("nspluginurl");
  +	    String codebase = n.getTextAttribute("codebase");
  +	    String archive = n.getTextAttribute("archive");
  +	    String jreversion = n.getTextAttribute("jreversion");
               
               String widthStr = null;
               if( width != null ) {
  @@ -1821,7 +1821,7 @@
   
                   public void visit(Node.ParamAction n) throws JasperException {
   		    out.printin("_jspx_params.put(");
  -		    out.print(quote(n.getAttributeValue("name")));
  +		    out.print(quote(n.getTextAttribute("name")));
   		    out.print(", ");
   		    out.print(attributeValue(n.getValue(), false,
   					     String.class, "null"));
  @@ -1837,20 +1837,20 @@
   	    }
   	    
   	    // Invoke fragment with parameter map
  -	    String varReaderAttr = n.getAttributeValue("varReader");
  -	    String varAttr = n.getAttributeValue("var");
  +	    String varReaderAttr = n.getTextAttribute("varReader");
  +	    String varAttr = n.getTextAttribute("var");
   	    if (varReaderAttr != null || varAttr != null) {
   		out.printil("_jspx_sout = new java.io.StringWriter();");
  -		out.print(toGetterMethod(n.getAttributeValue("fragment")));
  +		out.print(toGetterMethod(n.getTextAttribute("fragment")));
   		out.println(".invoke(_jspx_sout, _jspx_params);");
   	    } else {
  -		out.print(toGetterMethod(n.getAttributeValue("fragment")));
  +		out.print(toGetterMethod(n.getTextAttribute("fragment")));
   		out.println(".invoke(null, _jspx_params);");
   	    }
   
   	    // Store varReader in appropriate scope
   	    if (varReaderAttr != null || varAttr != null) {
  -		String scopeName = n.getAttributeValue("scope");
  +		String scopeName = n.getTextAttribute("scope");
   		out.printin("pageContext.setAttribute(");
   		if (varReaderAttr != null) {
   		    out.print(quote(varReaderAttr));
  @@ -1876,7 +1876,7 @@
   
                   public void visit(Node.ParamAction n) throws JasperException {
   		    out.printin("_jspx_params.put(");
  -		    out.print(quote(n.getAttributeValue("name")));
  +		    out.print(quote(n.getTextAttribute("name")));
   		    out.print(", ");
   		    out.print(attributeValue(n.getValue(), false,
   					     String.class, "null"));
  @@ -1918,8 +1918,8 @@
   	    }
   
   	    // Invoke body with parameter map
  -	    String varReaderAttr = n.getAttributeValue("varReader");
  -	    String varAttr = n.getAttributeValue("var");
  +	    String varReaderAttr = n.getTextAttribute("varReader");
  +	    String varAttr = n.getTextAttribute("var");
   	    if (varReaderAttr != null || varAttr != null) {
   		out.printil("_jspx_sout = new java.io.StringWriter();");
   		out.printil("getJspBody().invoke(_jspx_sout, _jspx_params);");
  @@ -1929,7 +1929,7 @@
   
   	    // Store varReader in appropriate scope
   	    if (varReaderAttr != null || varAttr != null) {
  -		String scopeName = n.getAttributeValue("scope");
  +		String scopeName = n.getTextAttribute("scope");
   		out.printin("pageContext.setAttribute(");
   		if (varReaderAttr != null) {
   		    out.print(quote(varReaderAttr));
  
  
  
  1.13      +12 -24    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspUtil.java
  
  Index: JspUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspUtil.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- JspUtil.java	21 Aug 2002 16:21:56 -0000	1.12
  +++ JspUtil.java	23 Aug 2002 23:56:53 -0000	1.13
  @@ -292,8 +292,7 @@
        * Checks if all mandatory attributes are present and if all attributes
        * present have valid names.  Checks attributes specified as XML-style
        * attributes as well as attributes specified using the jsp:attribute
  -     * standard action.  Also verifies that any attributes specified
  -     * via jsp:attribute are rtexprvalue attributes.
  +     * standard action. 
        */
       public static void checkAttributes(String typeOfTag,
   				       Node n,
  @@ -313,8 +312,7 @@
                   temp.addElement(qName);
           }
   
  -        // Add names of attributes specified using jsp:attribute and
  -        // check that they are rtexprvalues while we're at it.
  +        // Add names of attributes specified using jsp:attribute
           Node.Nodes tagBody = n.getBody();
           if( tagBody != null ) {
               int numSubElements = tagBody.size();
  @@ -322,22 +320,12 @@
                   Node node = tagBody.getNode( i );
                   if( node instanceof Node.NamedAttribute ) {
                       String attrName = node.getAttributeValue( "name" );
  -                    // Verify that this node is an rtexprvalue.
  -                    for( int j = 0; j < validAttributes.length; j++ ) {
  -                        if( validAttributes[j].name.equals( attrName ) &&
  -                            !validAttributes[j].rtexprvalue )
  -                        {
  -                            valid = false;
  -                            err.jspError(start,
  -                                         "jsp.error.named.attribute.not.rt",
  -                                         attrName );
  -                            break;
  -                        }
  -                    }
  -                    if( valid ) {
  -                        temp.addElement( attrName );
  -                    }
  -                    valid = true;
  +                    temp.addElement( attrName );
  +		    // Check if this value appear in the attribute of the node
  +		    if (n.getAttributeValue(attrName) != null) {
  +			err.jspError(n, "jsp.error.duplicate.name.jspattribute",
  +					attrName);
  +		    }
                   }
                   else {
                       // Nothing can come before jsp:attribute, and only
  @@ -470,7 +458,7 @@
       public static class ValidAttribute {
      	String name;
   	boolean mandatory;
  -	boolean rtexprvalue;
  +	boolean rtexprvalue;	// not used now
   
   	public ValidAttribute (String name, boolean mandatory,
               boolean rtexprvalue )
  
  
  
  1.30      +52 -3     jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java
  
  Index: Node.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- Node.java	22 Aug 2002 23:41:37 -0000	1.29
  +++ Node.java	23 Aug 2002 23:56:53 -0000	1.30
  @@ -85,6 +85,7 @@
       protected int beginJavaLine;
       protected int endJavaLine;
       protected Node parent;
  +    protected Nodes namedAttributeNodes; // cached for performance
   
       /**
        * Constructor.
  @@ -133,6 +134,47 @@
       }
   
       /**
  +     * Get the attribute that is non requrest time expression, either
  +     * from the attribute of the node, or from a jsp:attrbute 
  +     */
  +    public String getTextAttribute(String name) {
  +	class AttributeVisitor extends Visitor {
  +	    String attrValue = null;
  +	    public void visit(TemplateText txt) {
  +		attrValue = new String(txt.getText());
  +	    }
  +
  +	    public String getAttrValue() {
  +		return attrValue;
  +	    }
  +	}
  +
  +	String attr = getAttributeValue(name);
  +	if (attr != null) {
  +	    return attr;
  +	}
  +
  +	NamedAttribute namedAttribute = getNamedAttributeNode(name);
  +	if (namedAttribute == null) {
  +	    return null;
  +	}
  +
  +	// Get the attribute value from named attribute (jsp:attribute)
  +	// Since this method is only for attributes that are not rtexpr,
  +	// we can assume the body of the jsp:attribute is a template text
  +	if (namedAttribute.getBody() != null) {
  +	    AttributeVisitor attributeVisitor = new AttributeVisitor();
  +	    try {
  +		namedAttribute.getBody().visit(attributeVisitor);
  +	    } catch (JasperException e) {
  +	    }
  +	    attr = attributeVisitor.getAttrValue();
  +	}
  +
  +	return attr;
  +    }
  +
  +    /**
        * Searches all subnodes of this node for jsp:attribute standard
        * actions with the given name, and returns the NamedAttribute node
        * of the matching named attribute, nor null if no such node is found.
  @@ -162,6 +204,11 @@
        * actions, and returns that set of nodes as a Node.Nodes object.
        */
       public Node.Nodes getNamedAttributeNodes() {
  +
  +	if (namedAttributeNodes != null) {
  +	    return namedAttributeNodes;
  +	}
  +
           Node.Nodes result = new Node.Nodes();
           
           // Look for the attribute in NamedAttribute children
  @@ -181,6 +228,7 @@
               }
           }
   
  +	namedAttributeNodes = result;
           return result;
       }
       
  @@ -1578,6 +1626,7 @@
   
   	public void visit(GetProperty n) throws JasperException {
   	    doVisit(n);
  +	    visitBody(n);
   	}
   
   	public void visit(SetProperty n) throws JasperException {
  
  
  
  1.24      +96 -11    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Parser.java	20 Aug 2002 15:50:22 -0000	1.23
  +++ Parser.java	23 Aug 2002 23:56:53 -0000	1.24
  @@ -68,6 +68,7 @@
   import javax.servlet.jsp.tagext.TagLibraryInfo;
   import javax.servlet.jsp.tagext.TagInfo;
   import javax.servlet.jsp.tagext.TagFileInfo;
  +import javax.servlet.jsp.tagext.TagAttributeInfo;
   import org.xml.sax.Attributes;
   import org.xml.sax.helpers.AttributesImpl;
   import org.apache.jasper.Constants;
  @@ -103,6 +104,8 @@
           "JAVAX_BODY_CONTENT_PARAM";
       private static final String JAVAX_BODY_CONTENT_PLUGIN = 
           "JAVAX_BODY_CONTENT_PLUGIN";
  +    private static final String JAVAX_BODY_CONTENT_TEMPLATE_TEXT = 
  +        "JAVAX_BODY_CONTENT_TEMPLATE_TEXT";
   
       /**
        * The constructor
  @@ -685,7 +688,8 @@
   
           Node getPropertyNode = new Node.GetProperty( attrs, start, parent );
           
  -        parseEmptyBody( getPropertyNode, "jsp:getProperty" );
  +        parseOptionalBody(getPropertyNode, "jsp:getProperty",
  +			  TagInfo.BODY_CONTENT_EMPTY);
       }
   
       /*
  @@ -698,7 +702,8 @@
   
           Node setPropertyNode = new Node.SetProperty( attrs, start, parent );
           
  -        parseEmptyBody( setPropertyNode, "jsp:setProperty" );
  +        parseOptionalBody(setPropertyNode, "jsp:setProperty",
  +			  TagInfo.BODY_CONTENT_EMPTY);
       }
   
       /*
  @@ -1157,7 +1162,7 @@
   
       /*
        * ScriptlessBody ::=   ( '<%--' JSPCommentBody )
  -     *			  | ( '<%@' <TRANSLATION_ERROR> )
  +     *			  | ( '<%@' DirectiveBody )
        *			  | ( '<%!' <TRANSLATION_ERROR> )
        *			  | ( '<%=' <TRANSLATION_ERROR> )
        *			  | ( '<%' <TRANSLATION_ERROR> )
  @@ -1196,9 +1201,43 @@
       }
       
       /*
  -     *
  +     * TemplateTextBody ::=   ( '<%--' JSPCommentBody )
  +     *                      | ( '<%@' DirectiveBody )
  +     *                      | ( '<%!' <TRANSLATION_ERROR> )
  +     *                      | ( '<%=' <TRANSLATION_ERROR> )
  +     *                      | ( '<%' <TRANSLATION_ERROR> )
  +     *                      | ( '${' <TRANSLATION_ERROR> )
  +     *                      | ( '<jsp:' <TRANSLATION_ERROR> )
  +     *                      | TemplateText
        */
  -    private void parseBodyText(Node parent, String tag) throws JasperException{
  +    private void parseElementsTemplateText(Node parent)
  +        throws JasperException
  +    {
  +        start = reader.mark();
  +        if (reader.matches("<%--")) {
  +            parseComment(parent);
  +        } else if (reader.matches("<%@")) {
  +            parseDirective(parent);
  +        } else if (reader.matches("<%!")) {
  +            err.jspError( reader.mark(), "jsp.error.not.in.template" );
  +        } else if (reader.matches("<%=")) {
  +            err.jspError( reader.mark(), "jsp.error.not.in.template" );
  +        } else if (reader.matches("<%")) {
  +            err.jspError( reader.mark(), "jsp.error.not.in.template" );
  +        } else if (reader.matches("${")) {
  +            err.jspError( reader.mark(), "jsp.error.not.in.template" );
  +        } else if (reader.matches("<jsp:")) {
  +            err.jspError( reader.mark(), "jsp.error.not.in.template" );
  +	} else {
  +            parseTemplateText(parent);
  +	}
  +    }
  +
  +    /**
  +     * TagDependentBody := 
  +     */
  +    private void parseTagDependentBody(Node parent, String tag)
  +		throws JasperException{
   	Mark bodyStart = reader.mark();
   	Mark bodyEnd = reader.skipUntilETag(tag);
   	if (bodyEnd == null) {
  @@ -1265,7 +1304,7 @@
           throws JasperException 
       {
           if( bodyType.equalsIgnoreCase( TagInfo.BODY_CONTENT_TAG_DEPENDENT ) ) {
  -            parseBodyText( parent, tag );
  +            parseTagDependentBody( parent, tag );
           }
           else if( bodyType.equalsIgnoreCase( TagInfo.BODY_CONTENT_EMPTY ) ) {
               if( !reader.matchesETag( tag ) ) {
  @@ -1283,7 +1322,8 @@
           }
           else if( bodyType.equalsIgnoreCase( TagInfo.BODY_CONTENT_JSP ) ||
               bodyType.equalsIgnoreCase( TagInfo.BODY_CONTENT_SCRIPTLESS ) ||
  -            (bodyType == JAVAX_BODY_CONTENT_PARAM) )
  +            (bodyType == JAVAX_BODY_CONTENT_PARAM) ||
  +            (bodyType == JAVAX_BODY_CONTENT_TEMPLATE_TEXT) )
           {
               while (reader.hasMoreInput()) {
                   if (reader.matchesETag(tag)) {
  @@ -1304,6 +1344,9 @@
                       reader.skipSpaces();
                       parseParam( parent );
                   }
  +		else if (bodyType == JAVAX_BODY_CONTENT_TEMPLATE_TEXT) {
  +		    parseElementsTemplateText(parent);
  +		}
               }
               err.jspError(start, "jsp.error.unterminated", "&lt;"+tag );
           }
  @@ -1349,7 +1392,7 @@
                       reader.skipSpaces();
                   }
                   parseBody( namedAttributeNode, "jsp:attribute", 
  -                    TagInfo.BODY_CONTENT_SCRIPTLESS );
  +		    getAttributeBodyType(parent, attrs.getValue("name")));
                   if( namedAttributeNode.isTrim() ) {
                       Node.Nodes subelements = namedAttributeNode.getBody();
                       Node lastNode = subelements.getNode(
  @@ -1363,5 +1406,47 @@
           } while( reader.matches( "<jsp:attribute" ) );
       }
   
  +    /**
  +     * Determine the body type of <jsp:attribute> from the enclosing node
  +     */
  +    private String getAttributeBodyType(Node n, String name) {
  +
  +	if (n instanceof Node.CustomTag) {
  +	    TagAttributeInfo[] tldAttrs =
  +			((Node.CustomTag)n).getTagInfo().getAttributes();
  +	    for (int i=0; i<tldAttrs.length; i++) {
  +		if (name.equals(tldAttrs[i].getName())) {
  +		    if (tldAttrs[i].isFragment()) {
  +		        return TagInfo.BODY_CONTENT_SCRIPTLESS;
  +		    }
  +		    if (tldAttrs[i].canBeRequestTime()) {
  +		        return TagInfo.BODY_CONTENT_JSP;
  +		    }
  +		}
  +	    }
  +	} else if (n instanceof Node.IncludeAction) {
  +	    if ("page".equals(name)) {
  +		return TagInfo.BODY_CONTENT_JSP;
  +	    }
  +	} else if (n instanceof Node.ForwardAction) {
  +	    if ("page".equals(name)) {
  +		return TagInfo.BODY_CONTENT_JSP;
  +	    }
  +	} else if (n instanceof Node.SetProperty) {
  +	    if ("value".equals(name)) {
  +		return TagInfo.BODY_CONTENT_JSP;
  +	    }
  +	} else if (n instanceof Node.UseBean) {
  +	    if ("beanName".equals(name)) {
  +		return TagInfo.BODY_CONTENT_JSP;
  +	    }
  +	} else if (n instanceof Node.PlugIn) {
  +	    if ("width".equals(name) || "height".equals(name)) {
  +		return TagInfo.BODY_CONTENT_JSP;
  +	    }
  +	}
  +
  +	return JAVAX_BODY_CONTENT_TEMPLATE_TEXT;
  +    }
   }
   
  
  
  
  1.29      +38 -36    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java
  
  Index: Validator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- Validator.java	22 Aug 2002 21:31:28 -0000	1.28
  +++ Validator.java	23 Aug 2002 23:56:53 -0000	1.29
  @@ -443,9 +443,9 @@
   	public void visit(Node.SetProperty n) throws JasperException {
               JspUtil.checkAttributes("SetProperty", n,
                                       setPropertyAttrs, err);
  -	    String name = n.getAttributeValue("name");
  -	    String property = n.getAttributeValue("property");
  -	    String param = n.getAttributeValue("param");
  +	    String name = n.getTextAttribute("name");
  +	    String property = n.getTextAttribute("property");
  +	    String param = n.getTextAttribute("param");
   	    String value = n.getAttributeValue("value");
   
               n.setValue(getJspAttribute("value", null, null, value, 
  @@ -468,10 +468,10 @@
               JspUtil.checkAttributes("UseBean", n,
                                       useBeanAttrs, err);
   
  -	    String name = n.getAttributeValue ("id");
  -	    String scope = n.getAttributeValue ("scope");
  -	    String className = n.getAttributeValue ("class");
  -	    String type = n.getAttributeValue ("type");
  +	    String name = n.getTextAttribute ("id");
  +	    String scope = n.getTextAttribute ("scope");
  +	    String className = n.getTextAttribute ("class");
  +	    String type = n.getTextAttribute ("type");
   	    BeanRepository beanInfo = pageInfo.getBeanRepository();
   
   	    if (className == null && type == null)
  @@ -511,12 +511,12 @@
   	public void visit(Node.PlugIn n) throws JasperException {
               JspUtil.checkAttributes("Plugin", n, plugInAttrs, err);
   
  -	    String type = n.getAttributeValue("type");
  +	    String type = n.getTextAttribute("type");
   	    if (type == null)
   		err.jspError(n, "jsp.error.plugin.notype");
   	    if (!type.equals("bean") && !type.equals("applet"))
   		err.jspError(n, "jsp.error.plugin.badtype");
  -	    if (n.getAttributeValue("code") == null)
  +	    if (n.getTextAttribute("code") == null)
   		err.jspError(n, "jsp.error.plugin.nocode");
               
   	    Node.JspAttribute width
  @@ -608,17 +608,25 @@
   	    /*
   	     * Make sure all required attributes are present, either as
                * attributes or named attributes (<jsp:attribute>).
  + 	     * Also Make sure that the same attribute is not specified in
  +	     * both attributes or named attributes.
   	     */
   	    TagAttributeInfo[] tldAttrs = tagInfo.getAttributes();
   	    Attributes attrs = n.getAttributes();
   	    for (int i=0; i<tldAttrs.length; i++) {
  +		String attr = attrs.getValue(tldAttrs[i].getName());
  +		Node.NamedAttribute jspAttr =
  +			n.getNamedAttributeNode(tldAttrs[i].getName());
  +		
   		if (tldAttrs[i].isRequired() &&
  -		    (attrs.getValue(tldAttrs[i].getName()) == null) &&
  -                    (n.getNamedAttributeNode(tldAttrs[i].getName()) == null) )
  -                {
  +			attr == null && jspAttr == null) {
   		    err.jspError(n, "jsp.error.missing_attribute",
   				 tldAttrs[i].getName(), n.getShortName());
   		}
  +		if (attr != null && jspAttr != null) {
  +		    err.jspError(n, "jsp.error.duplicate.name.jspattribute",
  +			tldAttrs[i].getName());
  +		}
   	    }
   
   	    /*
  @@ -706,32 +714,26 @@
   		boolean found = false;
   		for (int j=0; j<tldAttrs.length; j++) {
   		    if (na.getName().equals(tldAttrs[j].getName())) {
  -			if (tldAttrs[j].canBeRequestTime()) {
  -                            Class expectedType = String.class;
  -                            try {
  -                                String typeStr = tldAttrs[j].getTypeName();
  -                                if( tldAttrs[j].isFragment() ) {
  -                                    expectedType = JspFragment.class;
  -                                }
  -                                else if( typeStr != null ) {
  -                                    expectedType = Class.forName( typeStr );
  -                                }
  -                                jspAttrs[attrs.getLength() + i]
  +                        Class expectedType = String.class;
  +                        try {
  +                            String typeStr = tldAttrs[j].getTypeName();
  +                            if( tldAttrs[j].isFragment() ) {
  +                                expectedType = JspFragment.class;
  +                            }
  +                            else if( typeStr != null ) {
  +                                expectedType = Class.forName( typeStr );
  +                            }
  +                            jspAttrs[attrs.getLength() + i]
                                       = getJspAttribute(na.getName(), null, null,
                                                         null, expectedType, 
                                                         n.getPrefix(), n, false);
  -                            }
  -                            catch( ClassNotFoundException e ) {
  -                                err.jspError(n, 
  +                        }
  +                        catch( ClassNotFoundException e ) {
  +                            err.jspError(n, 
                                       "jsp.error.unknown_attribute_type",
                                       tldAttrs[j].getName(), 
                                       tldAttrs[j].getTypeName() );
  -                            }
  -			} else {
  -                            err.jspError( n, 
  -                                "jsp.error.named.attribute.not.rt",
  -                                na.getName() );
  -			}
  +                        }
                           tagDataAttrs.put(na.getName(),
                                            TagData.REQUEST_TIME_VALUE);
   			found = true;
  @@ -973,7 +975,7 @@
   	     * NESTED.
   	     */
   	    TagVariableInfo[] tagVars = tagInfo.getTagVariableInfos();
  -	    if (tagVars != null) {
  +	    if (tagVars != null && subelements != null) {
   		for (int i=0; i<tagVars.length; i++) {
   		    if (tagVars[i].getScope() == VariableInfo.AT_END)
   			continue;
  
  
  
  1.32      +3 -3      jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages.properties
  
  Index: messages.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages.properties,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- messages.properties	22 Aug 2002 21:31:28 -0000	1.31
  +++ messages.properties	23 Aug 2002 23:56:54 -0000	1.32
  @@ -265,8 +265,6 @@
   jsp.error.empty.body.not.allowed=Empty body not allowed for {0}
   jsp.error.jspbody.body.not.allowed.with.value=Body not allowed for jsp:body if any attributes
(such as value) are specified.
   
  -jsp.error.named.attribute.not.rt=Cannot use jsp:attribute to specify value for non-request-time-attribute
{0}.
  -
   jsp.error.jspbody.required=Must use jsp:body to specify tag body for {0} if jsp:attribute
is used.
   
   jsp.error.jspbody.emptybody.only=The {0} tag can only have jsp:attribute in its body.
  @@ -297,3 +295,5 @@
   jsp.warning.bad.urlpattern.propertygroup=Bad value {0} in the url-pattern subelement in
web.xml
   jsp.error.unknown_attribute_type=Unknown attribute type ({1}) for attribute {0}.
   jsp.error.jspelement.missing.name=Mandatory attribute 'name' missing in jsp:element
  +jsp.error.duplicate.name.jspattribute=The attribute {0} specified in the standard or custom
action also appears as the value of the name attribute in the enclosed jsp:attribute
  +jsp.error.not.in.template=Not allowed in a template text body.
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message