Author: remy.maucherat(a)jboss.com
Date: 2009-11-09 20:01:04 -0500 (Mon, 09 Nov 2009)
New Revision: 1258
Modified:
trunk/java/org/apache/jasper/compiler/Compiler.java
trunk/java/org/apache/jasper/compiler/JspConfig.java
trunk/java/org/apache/jasper/compiler/PageInfo.java
Log:
- Add the three new jsp-property-group elements.
Modified: trunk/java/org/apache/jasper/compiler/Compiler.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/Compiler.java 2009-11-09 15:24:30 UTC (rev
1257)
+++ trunk/java/org/apache/jasper/compiler/Compiler.java 2009-11-10 01:01:04 UTC (rev
1258)
@@ -139,6 +139,16 @@
pageInfo.setTrimDirectiveWhitespaces(JspUtil.booleanValue(jspProperty
.isTrimDirectiveWhitespaces()));
}
+ if (jspProperty.getDefaultContentType() != null &&
pageInfo.getContentType() == null) {
+ pageInfo.setContentType(jspProperty.getDefaultContentType());
+ }
+ if (jspProperty.getBuffer() != null && pageInfo.getBufferValue() == null)
{
+ pageInfo.setBufferValue(jspProperty.getBuffer(), errDispatcher);
+ }
+ if (jspProperty.isErrorOnUndeclaredNamespace() != null) {
+ pageInfo.setErrorOnUndeclaredNamespace(JspUtil.booleanValue(jspProperty
+ .isErrorOnUndeclaredNamespace()));
+ }
ctxt.checkOutputDir();
String javaFileName = ctxt.getServletJavaFileName();
Modified: trunk/java/org/apache/jasper/compiler/JspConfig.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/JspConfig.java 2009-11-09 15:24:30 UTC (rev
1257)
+++ trunk/java/org/apache/jasper/compiler/JspConfig.java 2009-11-10 01:01:04 UTC (rev
1258)
@@ -46,8 +46,6 @@
package org.apache.jasper.compiler;
-import java.io.InputStream;
-import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -56,10 +54,7 @@
import org.apache.catalina.Globals;
import org.apache.jasper.JasperException;
-import org.apache.jasper.xmlparser.ParserUtils;
-import org.apache.jasper.xmlparser.TreeNode;
import org.jboss.logging.Logger;
-import org.xml.sax.InputSource;
/**
* Handles the jsp-config element in WEB_INF/web.xml. This is used
@@ -84,6 +79,9 @@
private String defaultDeferedSyntaxAllowedAsLiteral = null;
private String defaultTrimDirectiveWhitespaces = null;
private JspProperty defaultJspProperty;
+ private String defaultDefaultContentType = null;
+ private String defaultBuffer = null;
+ private String defaultErrorOnUndeclaredNamespace = null;
public JspConfig(ServletContext ctxt) {
this.ctxt = ctxt;
@@ -161,7 +159,10 @@
jspPropertyGroup.getIncludePreludes(),
jspPropertyGroup.getIncludeCodas(),
jspPropertyGroup.getDeferredSyntaxAllowedAsLiteral(),
- jspPropertyGroup.getTrimDirectiveWhitespaces());
+ jspPropertyGroup.getTrimDirectiveWhitespaces(),
+ jspPropertyGroup.getDefaultContentType(),
+ jspPropertyGroup.getBuffer(),
+ jspPropertyGroup.getErrorOnUndeclaredNamespace());
JspPropertyGroup propertyGroup =
new JspPropertyGroup(path, extension, property);
@@ -173,7 +174,8 @@
defaultIsELIgnored,
defaultIsScriptingInvalid,
null, null, null, defaultDeferedSyntaxAllowedAsLiteral,
- defaultTrimDirectiveWhitespaces);
+ defaultTrimDirectiveWhitespaces, defaultDefaultContentType,
+ defaultBuffer, defaultErrorOnUndeclaredNamespace);
initialized = true;
}
}
@@ -251,6 +253,9 @@
JspPropertyGroup pageEncodingMatch = null;
JspPropertyGroup deferedSyntaxAllowedAsLiteralMatch = null;
JspPropertyGroup trimDirectiveWhitespacesMatch = null;
+ JspPropertyGroup defaultContentTypeMatch = null;
+ JspPropertyGroup bufferMatch = null;
+ JspPropertyGroup errorOnUndeclaredNamespaceMatch = null;
Iterator<JspPropertyGroup> iter = jspProperties.iterator();
while (iter.hasNext()) {
@@ -313,15 +318,28 @@
trimDirectiveWhitespacesMatch =
selectProperty(trimDirectiveWhitespacesMatch, jpg);
}
+ if (jp.getDefaultContentType() != null) {
+ defaultContentTypeMatch =
+ selectProperty(defaultContentTypeMatch, jpg);
+ }
+ if (jp.getBuffer() != null) {
+ bufferMatch = selectProperty(bufferMatch, jpg);
+ }
+ if (jp.isErrorOnUndeclaredNamespace() != null) {
+ errorOnUndeclaredNamespaceMatch =
+ selectProperty(errorOnUndeclaredNamespaceMatch, jpg);
+ }
}
-
String isXml = defaultIsXml;
String isELIgnored = defaultIsELIgnored;
String isScriptingInvalid = defaultIsScriptingInvalid;
String pageEncoding = null;
String isDeferedSyntaxAllowedAsLiteral = defaultDeferedSyntaxAllowedAsLiteral;
String isTrimDirectiveWhitespaces = defaultTrimDirectiveWhitespaces;
+ String defaultContentType = defaultDefaultContentType;
+ String buffer = defaultBuffer;
+ String isErrorOnUnderclaredNamespace = defaultErrorOnUndeclaredNamespace;
if (isXmlMatch != null) {
isXml = isXmlMatch.getJspProperty().isXml();
@@ -344,10 +362,22 @@
isTrimDirectiveWhitespaces =
trimDirectiveWhitespacesMatch.getJspProperty().isTrimDirectiveWhitespaces();
}
+ if (defaultContentTypeMatch != null) {
+ defaultContentType =
+ defaultContentTypeMatch.getJspProperty().getDefaultContentType();
+ }
+ if (bufferMatch != null) {
+ buffer = bufferMatch.getJspProperty().getBuffer();
+ }
+ if (errorOnUndeclaredNamespaceMatch != null) {
+ isErrorOnUnderclaredNamespace =
+
errorOnUndeclaredNamespaceMatch.getJspProperty().isErrorOnUndeclaredNamespace();
+ }
return new JspProperty(isXml, isELIgnored, isScriptingInvalid,
pageEncoding, includePreludes, includeCodas,
- isDeferedSyntaxAllowedAsLiteral, isTrimDirectiveWhitespaces);
+ isDeferedSyntaxAllowedAsLiteral, isTrimDirectiveWhitespaces,
+ defaultContentType, buffer, isErrorOnUnderclaredNamespace);
}
/**
@@ -432,12 +462,16 @@
private ArrayList<String> includeCoda;
private String deferedSyntaxAllowedAsLiteral;
private String trimDirectiveWhitespaces;
+ private String defaultContentType;
+ private String buffer;
+ private String errorOnUndeclaredNamespace;
public JspProperty(String isXml, String elIgnored,
String scriptingInvalid, String pageEncoding,
ArrayList<String> includePrelude, ArrayList<String>
includeCoda,
String deferedSyntaxAllowedAsLiteral,
- String trimDirectiveWhitespaces) {
+ String trimDirectiveWhitespaces, String defaultContentType,
+ String buffer, String errorOnUndeclaredNamespace) {
this.isXml = isXml;
this.elIgnored = elIgnored;
@@ -447,6 +481,9 @@
this.includeCoda = includeCoda;
this.deferedSyntaxAllowedAsLiteral = deferedSyntaxAllowedAsLiteral;
this.trimDirectiveWhitespaces = trimDirectiveWhitespaces;
+ this.defaultContentType = defaultContentType;
+ this.buffer = buffer;
+ this.errorOnUndeclaredNamespace = errorOnUndeclaredNamespace;
}
public String isXml() {
@@ -480,5 +517,17 @@
public String isTrimDirectiveWhitespaces() {
return trimDirectiveWhitespaces;
}
+
+ public String getDefaultContentType() {
+ return defaultContentType;
+ }
+
+ public String getBuffer() {
+ return buffer;
+ }
+
+ public String isErrorOnUndeclaredNamespace() {
+ return errorOnUndeclaredNamespace;
+ }
}
}
Modified: trunk/java/org/apache/jasper/compiler/PageInfo.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/PageInfo.java 2009-11-09 15:24:30 UTC (rev
1257)
+++ trunk/java/org/apache/jasper/compiler/PageInfo.java 2009-11-10 01:01:04 UTC (rev
1258)
@@ -81,6 +81,9 @@
private String trimDirectiveWhitespacesValue;
private boolean trimDirectiveWhitespaces = false;
+ // JSP 2.2
+ private boolean isErrorOnUndeclaredNamespace = false;
+
private String omitXmlDecl = null;
private String doctypeName = null;
private String doctypePublic = null;
@@ -469,6 +472,25 @@
bufferValue = value;
}
+ public void setBufferValue(String value, ErrorDispatcher err)
+ throws JasperException {
+
+ if ("none".equalsIgnoreCase(value))
+ buffer = 0;
+ else {
+ if (value == null || !value.endsWith("kb"))
+ err.jspError("jsp.error.page.invalid.buffer");
+ try {
+ Integer k = new Integer(value.substring(0, value.length()-2));
+ buffer = k.intValue() * 1024;
+ } catch (NumberFormatException e) {
+ err.jspError("jsp.error.page.invalid.buffer");
+ }
+ }
+
+ bufferValue = value;
+ }
+
public String getBufferValue() {
return bufferValue;
}
@@ -713,6 +735,14 @@
this.trimDirectiveWhitespaces = trimDirectiveWhitespaces;
}
+ public void setErrorOnUndeclaredNamespace(boolean s) {
+ isErrorOnUndeclaredNamespace = s;
+ }
+
+ public boolean isErrorOnUndeclaredNamespace() {
+ return isErrorOnUndeclaredNamespace;
+ }
+
public Set<String> getVarInfoNames() {
return varInfoNames;
}