cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Node.java Validator.java
luehe 2003/01/14 14:32:59 Modified:jasper2/src/share/org/apache/jasper/compiler Node.java Validator.java Log: Fixed 16077: Invalid error generated when translating a valid JSP document Revision ChangesPath 1.54 +6 -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.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- Node.java 11 Jan 2003 00:52:14 - 1.53 +++ Node.java 14 Jan 2003 22:32:58 - 1.54 @@ -195,6 +195,9 @@ /** * Searches all subnodes of this node for jsp:attribute standard * actions, and returns that set of nodes as a Node.Nodes object. + * + * @return Possibly empty Node.Nodes object containing any jsp:attribute + * subnodes of this Node */ public Node.Nodes getNamedAttributeNodes() { 1.66 +4 -4 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.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- Validator.java8 Jan 2003 18:42:43 - 1.65 +++ Validator.java14 Jan 2003 22:32:58 - 1.66 @@ -657,7 +657,7 @@ } public void visit(Node.UninterpretedTag n) throws JasperException { -if (n.getNamedAttributeNodes() != null) { +if (n.getNamedAttributeNodes().size() != 0) { err.jspError(n, jsp.error.namedAttribute.invalidUse); } } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Node.java Validator.java
luehe 2002/12/13 10:06:08 Modified:jasper2/src/share/org/apache/jasper/compiler Node.java Validator.java Log: Implemented JSP 2.0 clarification for TagData.getAttribute() regarding named attributes: If a static value is specified for an attribute that accepts a request-time attribute expression then that static value is returned, even if the value is provided in the body of a jsp:attribute action. The distinguished object REQUEST_TIME_VALUE is only returned if the value is specified as a request-time attribute expression or via the jsp:attribute with a body that contains dynamic content (scriptlets, scripting expressions, EL expressions, standard actions, or custom actions). Returns null if the attribute is not set. Revision ChangesPath 1.48 +39 -31 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.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- Node.java 12 Dec 2002 03:30:58 - 1.47 +++ Node.java 13 Dec 2002 18:06:08 - 1.48 @@ -145,16 +145,6 @@ * 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) { @@ -166,19 +156,7 @@ 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; + return namedAttribute.getText(); } /** @@ -922,7 +900,7 @@ */ public static class ChildInfo { private boolean scriptless; // true if the tag and its body - // contians no scripting elements. + // contain no scripting elements. private boolean hasUseBean; private boolean hasIncludeAction; private boolean hasSetProperty; @@ -1368,6 +1346,36 @@ public String getTemporaryVariableName() { return temporaryVariableName; } + + public String getText() { + + class AttributeVisitor extends Visitor { + String attrValue = null; + public void visit(TemplateText txt) { + attrValue = new String(txt.getText()); + } + + public String getAttrValue() { + return attrValue; + } + } + + // Get the attribute value from this 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 + String text = null; + if (getBody() != null) { + AttributeVisitor attributeVisitor = new AttributeVisitor(); + try { + getBody().visit(attributeVisitor); + } catch (JasperException e) { + } + text = attributeVisitor.getAttrValue(); + } + + return text; + } } /** @@ -1557,14 +1565,14 @@ * @return true if the value represents an expression that should * be fed to the expression interpreter * @return false for string literals or rtexprvalues that should - * not be interpreter or reevaluated + * not be interpreted or reevaluated */ public boolean isELInterpreterInput() { return el; } /** - * @return true if the value is a string literal know at translation + * @return true if the value is a string literal known at translation * time. */ public boolean isLiteral() { @@ -1654,8 +1662,8 @@ public static class Visitor { /** - * The method provides a place to put actions that are
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Node.java Validator.java
kinman 02/05/23 14:29:38 Modified:jasper2/src/share/org/apache/jasper/compiler Node.java Validator.java Log: - Set the default content type only after all page directives are processed. Also, the top level page sets the default, i.e. if a non-xml page includes a xml page, the default content type is text/html and not text/xml. Revision ChangesPath 1.9 +5 -4 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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- Node.java 15 May 2002 20:42:03 - 1.8 +++ Node.java 23 May 2002 21:29:38 - 1.9 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java,v 1.8 2002/05/15 20:42:03 kinman Exp $ - * $Revision: 1.8 $ - * $Date: 2002/05/15 20:42:03 $ + * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java,v 1.9 2002/05/23 21:29:38 kinman Exp $ + * $Revision: 1.9 $ + * $Date: 2002/05/23 21:29:38 $ * * * @@ -793,7 +793,7 @@ public static class Nodes { private List list; - private Node.Root root; + private Node.Root root; // null if this is not a page public Nodes() { list = new Vector(); @@ -811,6 +811,7 @@ */ public void add(Node n) { list.add(n); + root = null; } /** 1.8 +15 -13 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Validator.java18 May 2002 00:29:24 - 1.7 +++ Validator.java23 May 2002 21:29:38 - 1.8 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java,v 1.7 2002/05/18 00:29:24 kinman Exp $ - * $Revision: 1.7 $ - * $Date: 2002/05/18 00:29:24 $ + * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java,v 1.8 2002/05/23 21:29:38 kinman Exp $ + * $Revision: 1.8 $ + * $Date: 2002/05/23 21:29:38 $ * * * @@ -244,16 +244,6 @@ // Attributes for imports for this node have been processed by // the parsers, just add them to pageInfo. pageInfo.addImports(n.getImports()); - - // Determine the output context type, per errata_a - // http://jcp.org/aboutJava/communityprocess/maintenance/jsr053/errata_1_2_a_20020321.html - if (pageInfo.getContentType() == null) { - String defaultType = n.isXmlSyntax()? text/xml;: text/html;; - String charset = pageInfo.getPageEncoding(); - if (charset == null) - charset = n.isXmlSyntax()? UTF-8: ISO-8859-1; - pageInfo.setContentType(defaultType + charset); - } } } @@ -613,6 +603,18 @@ * and are position independent. */ page.visit(new PageDirectiveVisitor(compiler)); + + // Determine the default output content type, per errata_a + // http://jcp.org/aboutJava/communityprocess/maintenance/jsr053/errata_1_2_a_20020321.html + PageInfo pageInfo = compiler.getPageInfo(); + if (pageInfo.getContentType() == null) { + boolean isXml = page.getRoot().isXmlSyntax(); + String defaultType = isXml? text/xml;: text/html;; + String charset = pageInfo.getPageEncoding(); + if (charset == null) + charset = isXml? UTF-8: ISO-8859-1; + pageInfo.setContentType(defaultType + charset); + } /* * Validate all other nodes. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]