You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by lu...@apache.org on 2002/11/06 21:58:11 UTC
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler PageDataImpl.java
luehe 2002/11/06 12:58:10
Modified: jasper2/src/share/org/apache/jasper/compiler
PageDataImpl.java
Log:
In XML view, always create page directive with 'contentType' and
'pageDirective' attributes, and append it right after the <jsp:root>
start element, and suppress the 'contentType' and 'pageDirective'
attributes from any subsequent page directive
Revision Changes Path
1.16 +35 -7 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java
Index: PageDataImpl.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- PageDataImpl.java 6 Nov 2002 20:14:19 -0000 1.15
+++ PageDataImpl.java 6 Nov 2002 20:58:10 -0000 1.16
@@ -405,8 +405,11 @@
if (attrs != null) {
printAttributes(attrs);
}
- if (body != null || text != null) {
+ if (tag.equals(JSP_ROOT) || body != null || text != null) {
buf.append(">\n");
+ if (tag.equals(JSP_ROOT)) {
+ appendPageDirective();
+ }
if (body != null) {
body.visit(this);
} else {
@@ -441,8 +444,15 @@
int len = attrs.getLength();
for (int i=0; i<len; i++) {
String attrName = attrs.getQName(i);
- if ("import".equals(attrName)) {
- // Ignore page directive's import attribute for now
+ if ("import".equals(attrName) || "contentType".equals(attrName)
+ || "pageEncoding".equals(attrName)) {
+ /*
+ * Page directive's 'import' attribute is considered
+ * further down, and its 'pageEncoding' and 'contentType'
+ * attributes are ignored, since we've already created
+ * a new page directive containing just these two
+ * attributes
+ */
continue;
}
String value = attrs.getValue(i);
@@ -479,6 +489,7 @@
appendCDATA(text);
buf.append(JSP_TEXT_END);
+ buf.append("\n");
} else {
appendCDATA(text);
}
@@ -537,7 +548,24 @@
* Appends XML prolog with encoding declaration.
*/
private void appendXmlProlog() {
- buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
+ buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
+ }
+
+ /*
+ * Appends a page directive with 'pageEncoding' and 'contentType'
+ * attributes whose values are derived from pageInfo.
+ */
+ private void appendPageDirective() {
+ buf.append("<").append(JSP_PAGE_DIRECTIVE);
+ buf.append("\n");
+
+ // append jsp:id
+ buf.append(" ").append("jsp:id").append("=\"");
+ buf.append(jspId++).append("\"\n");
+ buf.append(" ").append("pageEncoding").append("=\"UTF-8\"\n");
+ buf.append(" ").append("contentType").append("=\"");
+ buf.append(pageInfo.getContentType()).append("\"\n");
+ buf.append("/>\n");
}
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>