title: How to read request.getInputStream() multiple times
body: <p>I have this code:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Override
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
          throws IOException, ServletException {
      logger.info("Filter start...");
  
      HttpServletRequest httpRequest = (HttpServletRequest) request;
      HttpServletResponse httpResponse = (HttpServletResponse) response;
  
      String ba = getBaId(getBody(httpRequest));
  
      if (ba == null) {
          logger.error("Wrong XML");
          httpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      } else {      
  
          if (!clients.containsKey(ba)) {
              clients.put(ba, 1);
              logger.info("Client map : init...");
          } else {
              clients.put(ba, clients.get(ba).intValue() + 1);
              logger.info("Threads for " + ba + " = " + clients.get(ba).toString());
          }
  
          chain.doFilter(request, response);
      }
  }
  </code></pre>
  
  <p>and this web.xml (packages are shortened and names changed, but it looks the same)</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;web-app&gt;
    &lt;filter&gt;
      &lt;filter-name&gt;TestFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;pkg.TestFilter&lt;/filter-class&gt;
    &lt;/filter&gt;
    &lt;filter-mapping&gt;
      &lt;filter-name&gt;TestFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/filter-mapping&gt;
  
    &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;WEB-INF/applicationContext.xml&lt;/param-value&gt;
    &lt;/context-param&gt;
  
    &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
    &lt;/listener&gt;
  
    &lt;servlet&gt;
      &lt;servlet-name&gt;Name&lt;/servlet-name&gt;
      &lt;display-name&gt;Name&lt;/display-name&gt;
      &lt;servlet-class&gt;pkg.Name&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Name&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/services/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>I want to invoke the Servlet after the Filter. I was hoping <code>chain.doFilter(...)</code> could do the trick, but i always get this error on the line with <code>chain.doFilter(...)</code>:</p>
  
  <pre class="lang-none prettyprint-override"><code>java.lang.IllegalStateException: getInputStream() can't be called after getReader()
  at com.caucho.server.connection.AbstractHttpRequest.getInputStream(AbstractHttpRequest.java:1933)
  at org.apache.cxf.transport.http.AbstractHTTPDestination.setupMessage(AbstractHTTPDestination.java:249)
  at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:82)
  at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:283)
  at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:166)
  at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:174)
  at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:152)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:153)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:91)
  at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103)
  at pkg.TestFilter.doFilter(TestFilter.java:102)
  at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
  at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:187)
  at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:265)
  at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:273)
  at com.caucho.server.port.TcpConnection.run(TcpConnection.java:682)
  at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:743)
  at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:662)
  at java.lang.Thread.run(Thread.java:619)
  </code></pre>