title: How to use the URL http://localhost:8080/appcontext/META-INF/index.html?
body: <p>I have an example application that is running locally as <code>http://localhost:8080/appcontext</code> (the context is <code>/appcontext</code>).</p>
  
  <p>Now when <code>http://localhost:8080/appcontext/META-INF/index.html</code> is accessed in a browser I want to display the text <code>Hello, World!</code>.</p>
  
  <p><strong>Code for Servlet Mappings</strong></p>
  
  <p>This is how I tried to map a Servlet to the <code>/META-INF</code> URL. But it didn't work:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"
  &gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;MyServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;com.example.mapmetainf.MyServlet&lt;/servlet-class&gt;
      &lt;/servlet&gt;
  
      &lt;!--
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;MyServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/META-INF/index.html&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      --&gt;
  
      &lt;!--
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;MyServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/META-INF/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      --&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;MyServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>Servlet Specification</strong></p>
  
  <p>Java Servlet Specification 3.1, Chapter SRV.9.6 Web Application Archive File:</p>
  
  <blockquote>
    <p>This directory must not be directly served as content by the container in response to a Web client’s request, [...]. Also, any requests to access the resources in META-INF
    directory must be returned with a SC_NOT_FOUND(404) response.</p>
  </blockquote>
  
  <p>This forbids the direct mapping of the <code>META-INF</code> directory of the .war. But I don't think it forbids mapping a Servlet to the <code>/appcontext/META-INF</code> URL.</p>