title: The server encountered an unexpected condition that prevented it from fulfilling the request. HTTP 500
body: <p>I want to use one servlet for many pages. when i try to run the project, an error occurs because the request is full. have tried many options for URL patterns, but nothing comes out</p>
  
  <p>right now, i see only one way. to use only post methods and have empty url-pattern but i'm not sure that it is right choice :D</p>
  
  <pre class="lang-java prettyprint-override"><code>&lt;web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
           version="4.0"&gt;
    &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt;
  
    &lt;session-config&gt;
      &lt;session-timeout&gt;10&lt;/session-timeout&gt;
    &lt;/session-config&gt;
  
    &lt;filter&gt;
      &lt;filter-name&gt;InitialFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;eshop.filter.InitialFilter&lt;/filter-class&gt;
  
      &lt;init-param&gt;
        &lt;param-name&gt;encoding&lt;/param-name&gt;
        &lt;param-value&gt;UTF-8&lt;/param-value&gt;
      &lt;/init-param&gt;
  
    &lt;/filter&gt;
  
    &lt;filter&gt;
    &lt;filter-name&gt;SessionFilter&lt;/filter-name&gt;
    &lt;filter-class&gt;eshop.filter.SessionFilter&lt;/filter-class&gt;
    &lt;/filter&gt;
  
    &lt;filter-mapping&gt;
      &lt;filter-name&gt;InitialFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/filter-mapping&gt;
  
    &lt;filter-mapping&gt;
      &lt;filter-name&gt;SessionFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/filter-mapping&gt;
  
    &lt;servlet&gt;
      &lt;servlet-name&gt;mainServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;eshop.controller.MainServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;0&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;mainServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.jsp&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
      &lt;error-page&gt;
          &lt;location&gt;/WEB-INF/views/error.jsp&lt;/location&gt;
      &lt;/error-page&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>    public class IndexCommand implements Command {
  
          @Override
          public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, MessagingException, ServiceException, SQLException {
              if (request.getSession().getAttribute("role")=="admin")
              {
                  Command command=new AccountCommand();
                  command.execute(request,response);
              }
              System.out.println(request.getRequestURI());
              request.getRequestDispatcher("/WEB-INF/views/startPage.jsp").forward(request,response);
          }
  
      }
  </code></pre>
  
  <pre><code>    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              Command command = CommandFactory.createCommand(request);
              try {
                  command.execute(request, response);
              } catch (MessagingException e) {
                  e.printStackTrace();
              } catch (SQLException e) {
                  e.printStackTrace();
              } catch (ServiceException e) {
                  e.printStackTrace();
              }
  
          }
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>    Type Exception Report
  
      Message Servlet execution threw an exception
  
      Description The server encountered an unexpected condition that prevented it from fulfilling the request.
  
      Exception
  
      javax.servlet.ServletException: Servlet execution threw an exception
          org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
          eshop.command.IndexCommand.execute(IndexCommand.java:34)
          eshop.controller.MainServlet.doGet(MainServlet.java:62)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
          org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
          eshop.command.IndexCommand.execute(IndexCommand.java:34)
          eshop.controller.MainServlet.doGet(MainServlet.java:62)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
          org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  
      Root Cause
  
      java.lang.StackOverflowError
          eshop.command.IndexCommand.execute(IndexCommand.java:34)
          eshop.controller.MainServlet.doGet(MainServlet.java:62)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
          org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  
  </code></pre>
  
  <p>How to configure web.xml to map a servlet to more than one url pattern in Java and where is the problem?</p>