tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r893209 - in /tomcat/trunk/java/org/apache/jasper: compiler/Compiler.java compiler/JspConfig.java compiler/PageInfo.java compiler/Parser.java resources/LocalStrings.properties
Date Tue, 22 Dec 2009 15:44:54 GMT
Author: markt
Date: Tue Dec 22 15:44:54 2009
New Revision: 893209

URL: http://svn.apache.org/viewvc?rev=893209&view=rev
Log:
JSP 2.2 implementation (partial)
 - JSP 3.3.9  - Default content type
 - JSP 3.3.10 - Default buffer size
 - JSP 3.3.11 - Error on undeclared namespace

Modified:
    tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java
    tomcat/trunk/java/org/apache/jasper/compiler/JspConfig.java
    tomcat/trunk/java/org/apache/jasper/compiler/PageInfo.java
    tomcat/trunk/java/org/apache/jasper/compiler/Parser.java
    tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties

Modified: tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java?rev=893209&r1=893208&r2=893209&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java Tue Dec 22 15:44:54 2009
@@ -140,6 +140,18 @@
             pageInfo.setTrimDirectiveWhitespaces(JspUtil.booleanValue(jspProperty
                     .isTrimDirectiveWhitespaces()));
         }
+        if (jspProperty.getDefaultContentType() != null) {
+            pageInfo.setContentType(jspProperty.getDefaultContentType());
+        }
+        if (jspProperty.getBuffer() != null) {
+            pageInfo.setBufferValue(jspProperty.getBuffer(), null,
+                    errDispatcher);
+        }
+        if (jspProperty.isErrorOnUndeclaredNamespace() != null) {
+            pageInfo.setErrorOnUndeclaredNamespace(
+                    JspUtil.booleanValue(
+                            jspProperty.isErrorOnUndeclaredNamespace()));
+        }
 
         ctxt.checkOutputDir();
         String javaFileName = ctxt.getServletJavaFileName();

Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspConfig.java?rev=893209&r1=893208&r2=893209&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JspConfig.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JspConfig.java Tue Dec 22 15:44:54 2009
@@ -55,6 +55,9 @@
     private String defaultIsScriptingInvalid = null;
     private String defaultDeferedSyntaxAllowedAsLiteral = null;
     private String defaultTrimDirectiveWhitespaces = null;
+    private String defaultDefaultContentType = null;
+    private String defaultBuffer = null;
+    private String defaultErrorOnUndeclaredNamespace = "false";
     private JspProperty defaultJspProperty;
 
     public JspConfig(ServletContext ctxt) {
@@ -117,6 +120,9 @@
                 Vector<String> includeCoda = new Vector<String>();
                 String deferredSyntaxAllowedAsLiteral = null;
                 String trimDirectiveWhitespaces = null;
+                String defaultContentType = null;
+                String buffer = null;
+                String errorOnUndeclaredNamespace = null;
 
                 while (list.hasNext()) {
 
@@ -141,6 +147,12 @@
                         deferredSyntaxAllowedAsLiteral = element.getBody();
                     else if ("trim-directive-whitespaces".equals(tname))
                         trimDirectiveWhitespaces = element.getBody();
+                    else if ("default-content-type".equals(tname))
+                        defaultContentType = element.getBody();
+                    else if ("buffer".equals(tname))
+                        buffer = element.getBody();
+                    else if ("error-on-undeclared-namespace".equals(tname))
+                        errorOnUndeclaredNamespace = element.getBody();
                 }
 
                 if (urlPatterns.size() == 0) {
@@ -197,7 +209,10 @@
                             includePrelude,
                             includeCoda,
                             deferredSyntaxAllowedAsLiteral,
-                            trimDirectiveWhitespaces);
+                            trimDirectiveWhitespaces,
+                            defaultContentType,
+                            buffer,
+                            errorOnUndeclaredNamespace);
                     JspPropertyGroup propertyGroup =
                         new JspPropertyGroup(path, extension, property);
 
@@ -225,7 +240,10 @@
                             defaultIsELIgnored,
                             defaultIsScriptingInvalid,
                             null, null, null, defaultDeferedSyntaxAllowedAsLiteral, 
-                            defaultTrimDirectiveWhitespaces);
+                            defaultTrimDirectiveWhitespaces,
+                            defaultDefaultContentType,
+                            defaultBuffer,
+                            defaultErrorOnUndeclaredNamespace);
                     initialized = true;
                 }
             }
@@ -303,6 +321,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()) {
@@ -365,6 +386,17 @@
                 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);
+            }
         }
 
 
@@ -372,8 +404,12 @@
         String isELIgnored = defaultIsELIgnored;
         String isScriptingInvalid = defaultIsScriptingInvalid;
         String pageEncoding = null;
-        String isDeferedSyntaxAllowedAsLiteral = defaultDeferedSyntaxAllowedAsLiteral;
+        String isDeferedSyntaxAllowedAsLiteral =
+            defaultDeferedSyntaxAllowedAsLiteral;
         String isTrimDirectiveWhitespaces = defaultTrimDirectiveWhitespaces;
+        String defaultContentType = defaultDefaultContentType;
+        String buffer = defaultBuffer;
+        String errorOnUndelcaredNamespace = defaultErrorOnUndeclaredNamespace;
 
         if (isXmlMatch != null) {
             isXml = isXmlMatch.getJspProperty().isXml();
@@ -396,10 +432,22 @@
             isTrimDirectiveWhitespaces =
                 trimDirectiveWhitespacesMatch.getJspProperty().isTrimDirectiveWhitespaces();
         }
+        if (defaultContentTypeMatch != null) {
+            defaultContentType =
+                defaultContentTypeMatch.getJspProperty().getDefaultContentType();
+        }
+        if (bufferMatch != null) {
+            buffer = bufferMatch.getJspProperty().getBuffer();
+        }
+        if (errorOnUndeclaredNamespaceMatch != null) {
+            errorOnUndelcaredNamespace =
+                errorOnUndeclaredNamespaceMatch.getJspProperty().isErrorOnUndeclaredNamespace();
+        }
 
         return new JspProperty(isXml, isELIgnored, isScriptingInvalid,
                 pageEncoding, includePreludes, includeCodas, 
-                isDeferedSyntaxAllowedAsLiteral, isTrimDirectiveWhitespaces);
+                isDeferedSyntaxAllowedAsLiteral, isTrimDirectiveWhitespaces,
+                defaultContentType, buffer, errorOnUndelcaredNamespace);
     }
 
     /**
@@ -483,12 +531,18 @@
         private Vector<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,
                 Vector<String> includePrelude, Vector<String> includeCoda,
                 String deferedSyntaxAllowedAsLiteral, 
-                String trimDirectiveWhitespaces) {
+                String trimDirectiveWhitespaces,
+                String defaultContentType,
+                String buffer,
+                String errorOnUndeclaredNamespace) {
 
             this.isXml = isXml;
             this.elIgnored = elIgnored;
@@ -498,6 +552,9 @@
             this.includeCoda = includeCoda;
             this.deferedSyntaxAllowedAsLiteral = deferedSyntaxAllowedAsLiteral;
             this.trimDirectiveWhitespaces = trimDirectiveWhitespaces;
+            this.defaultContentType = defaultContentType;
+            this.buffer = buffer;
+            this.errorOnUndeclaredNamespace = errorOnUndeclaredNamespace;
         }
 
         public String isXml() {
@@ -531,5 +588,17 @@
         public String isTrimDirectiveWhitespaces() {
             return trimDirectiveWhitespaces;
         }
+        
+        public String getDefaultContentType() {
+            return defaultContentType;
+        }
+        
+        public String getBuffer() {
+            return buffer;
+        }
+        
+        public String isErrorOnUndeclaredNamespace() {
+            return errorOnUndeclaredNamespace;
+        }
     }
 }

Modified: tomcat/trunk/java/org/apache/jasper/compiler/PageInfo.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/PageInfo.java?rev=893209&r1=893208&r2=893209&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/PageInfo.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/PageInfo.java Tue Dec 22 15:44:54 2009
@@ -95,6 +95,8 @@
     private Vector<String> includeCoda;
     private Vector<String> pluginDcls;      // Id's for tagplugin declarations
 
+    // JSP 2.2
+    private boolean errorOnUndeclaredNamepsace = false;
 
     PageInfo(BeanRepository beanRepository, String jspFile) {
 
@@ -454,13 +456,22 @@
         if ("none".equalsIgnoreCase(value))
             buffer = 0;
         else {
-            if (value == null || !value.endsWith("kb"))
-                err.jspError(n, "jsp.error.page.invalid.buffer");
+            if (value == null || !value.endsWith("kb")) {
+                if (n == null) {
+                    err.jspError("jsp.error.page.invalid.buffer");
+                } else {
+                    err.jspError(n, "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(n, "jsp.error.page.invalid.buffer");
+                if (n == null) {
+                    err.jspError("jsp.error.page.invalid.buffer");
+                } else {
+                    err.jspError(n, "jsp.error.page.invalid.buffer");
+                }
             }
         }
 
@@ -714,4 +725,13 @@
     public Set<String> getVarInfoNames() {
         return varInfoNames;
     }
+    
+    public boolean isErrorOnUndeclaredNamespace() {
+        return errorOnUndeclaredNamepsace;
+    }
+    
+    public void setErrorOnUndeclaredNamespace(
+            boolean errorOnUndeclaredNamespace) {
+        this.errorOnUndeclaredNamepsace = errorOnUndeclaredNamespace; 
+    }
 }

Modified: tomcat/trunk/java/org/apache/jasper/compiler/Parser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Parser.java?rev=893209&r1=893208&r2=893209&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Parser.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Parser.java Tue Dec 22 15:44:54 2009
@@ -1217,10 +1217,14 @@
         // Check if this is a user-defined tag.
         String uri = pageInfo.getURI(prefix);
         if (uri == null) {
-            reader.reset(start);
-            // Remember the prefix for later error checking
-            pageInfo.putNonCustomTagPrefix(prefix, reader.mark());
-            return false;
+            if (pageInfo.isErrorOnUndeclaredNamespace()) {
+                err.jspError(start, "jsp.error.undeclared_namespace", prefix);
+            } else {
+                reader.reset(start);
+                // Remember the prefix for later error checking
+                pageInfo.putNonCustomTagPrefix(prefix, reader.mark());
+                return false;
+            }
         }
 
         TagLibraryInfo tagLibInfo = pageInfo.getTaglib(uri);

Modified: tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties?rev=893209&r1=893208&r2=893209&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties Tue Dec 22 15:44:54
2009
@@ -159,6 +159,7 @@
 jsp.error.setproperty.beanInfoNotFound=setproperty: beanInfo for bean {0} not found
 jsp.error.setproperty.paramOrValue=setProperty: either param or value can be present
 jsp.error.setproperty.arrayVal=setProperty: can't set array property {0} through a string
constant value
+jsp.error.undeclared_namespace=A custom tag was encountered with an undeclared namespace
[{0}] 
 jsp.warning.keepgen=Warning: Invalid value for the initParam keepgenerated. Will use the
default value of \"false\"
 jsp.warning.xpoweredBy=Warning: Invalid value for the initParam xpoweredBy. Will use the
default value of \"false\"
 jsp.warning.enablePooling=Warning: Invalid value for the initParam enablePooling. Will use
the default value of \"true\"



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


Mime
View raw message