title: What is standard web.xml java header to get <jsp-config> tag working?
body: <p>I've got a GlassFish 3.1.2 app server and I've started using JSP pages so I'm interested in configuring the encoding correctly for UTF-8.</p>
  
  <p>My original working <code>web.xml</code> file started with</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
     "http://java.sun.com/dtd/web-app_2_3.dtd"&gt; 
  </code></pre>
  
  <p>but then I added the following to it to force UTF-8 encoding</p>
  
  <pre><code>&lt;jsp-config&gt;
     &lt;jsp-property-group&gt;
         &lt;url-pattern&gt;*.jsp&lt;/url-pattern&gt;
         &lt;page-encoding&gt;UTF-8&lt;/page-encoding&gt;
     &lt;/jsp-property-group&gt; 
  &lt;/jsp-config&gt;
  </code></pre>
  
  <p>and my GlassFish 3.1.2 server log file reported</p>
  
  <pre><code>Element type &lt;jsp-config&gt; must be declared web.xml
  </code></pre>
  
  <p>In an attempt to fix the error, I changed the start of my <code>web.xml</code> file to be</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;  
  &lt;web-app xmlns="http://java.sun.com/xml/ns/j2ee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
   version="2.4" &gt;
  </code></pre>
  
  <p>and now I'm getting a GlassFish server error</p>
  
  <pre><code>Invalid Deployment Descriptors in Deployment descriptor file WEB-INF/web.xml ...
  One of '{"http://java.sun.com/xml/ns/j2ee":servlet-class, 
           "http://java.sun.com/xml/ns/j2ee":jsp-file}' is expected.
  </code></pre>
  
  <p>Is my syntax off? How to get <code>&lt;jsp-config&gt;</code> working with header in <code>xml.web</code> file for version 2.3?</p>
  
  <p>UPDATE 1</p>
  
  <p>If I start the <code>web.xml</code> file as</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_3.xsd"
      version="2.3"&gt;
  
  &lt;display-name&gt;myApp&lt;/display-name&gt;
  &lt;description&gt;My Application&lt;/description&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;...&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;MessageBrokerServlet&lt;/servlet-name&gt;
      &lt;display-name&gt;MessageBrokerServlet&lt;/display-name&gt;
      &lt;servlet-class&gt;...&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;...&lt;/param-name&gt;
          &lt;param-value&gt;...&lt;/param-value&gt;
     &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet&gt;
    &lt;servlet-name&gt;Reg&lt;/servlet-name&gt;
    &lt;servlet-class&gt;com.mydomain.servlet.Reg&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
     &lt;servlet-name&gt;Reg&lt;/servlet-name&gt;
     &lt;url-pattern&gt;/reg&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  
  &lt;jsp-config&gt;
    &lt;jsp-property-group&gt;
        &lt;url-pattern&gt;*.jsp&lt;/url-pattern&gt;
        &lt;page-encoding&gt;UTF-8&lt;/page-encoding&gt;
    &lt;/jsp-property-group&gt;
  &lt;/jsp-config&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>I see this error:</p>
  
  <blockquote>
  <pre><code>[#|2014-11-06T13:03:59.779-0800|SEVERE|glassfish3.1.2|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=1;_ThreadName=Thread-2;|DPL8015:
  </code></pre>
    
    <p>Invalid Deployment Descriptors in Deployment descriptor file
    WEB-INF/web.xml in archive [myapp].  Line 7 Column 41 --
    s4s-elt-character: Non-whitespace characters are not allowed in schema
    elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'var _U =
    "undefined";    var g_HttpRelativeWebRoot = "/ocom/";'.|#]</p>
    
    <p>[#|2014-11-06T13:03:59.779-0800|SEVERE|glassfish3.1.2|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=1;_ThreadName=Thread-2;|DPL8005:
    Deployment Descriptor parsing failure : s4s-elt-character:
    Non-whitespace characters are not allowed in schema elements other
    than 'xs:appinfo'  and 'xs:documentation'. Saw 'var _U = "undefined"; 
    var g_HttpRelativeWebRoot = "/ocom/";'.|#]</p>
  </blockquote>
  
  <p>UPDATE 2</p>
  
  <p>Alternatively, I also have a <code>glassfish-web.xml</code> file in <code>WEB-INF</code> directory. If I revert the <code>web.xml</code> file back to original and place the <code>&lt;jsp-config&gt;</code> section in <code>glassfish-web.xml</code> instead of <code>web.xml</code>, the server starts fine. Which file is <code>&lt;jsp-config&gt;</code> supposed to go in, or does it matter?</p>