title: How can I map a "root" Servlet so that other scripts are still runnable?
body: <p>I'm trying to build a Servlet that calls a JSP page similar to the following:</p>
  
  <pre><code>public void doGet(HttpServletRequest req, HttpServletResponse resp)
          throws IOException, ServletException {
      req.getRequestDispatcher("/WEB-INF/main.jsp").forward(req, resp);
  }
  </code></pre>
  
  <p>I need this Servlet to respond to the domain's root (eg: <a href="http://example.com/" rel="noreferrer">http://example.com/</a>) so I'm using the following mapping in the web.xml:</p>
  
  <pre><code>&lt;servlet-mapping&gt;
      &lt;servlet-name&gt;MainServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>The problem I'm having is that this matches EVERYTHING, so when the dispatcher forwards to "/WEB-INF/main.jsp" this matches the url-pattern so the Servlet gets run again. This results in a loop that runs until it dies with a <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StackOverflowError.html" rel="noreferrer">java.lang.StackOverflowError</a>.</p>
  
  <p>How can I match the root without preventing other scripts from being runnable?</p>