title: Prevent IllegalStateException when reading from request
body: <p>I have an interceptor for catching Exceptions and sending emails of this exceptions.</p>
  
  <p>All my struts actions extend CoreController which implements SerlvetRequestAware.</p>
  
  <p>In mail service class then I have:</p>
  
  <pre><code>CoreController cc = (CoreController)invocation.getAction();
  HttpServletRequest request = cc.getRequest();
  </code></pre>
  
  <p>I want to insert request body to email, if exists. Like so:</p>
  
  <pre><code>StringWriter msg = new StringWriter();
  msg.write("Requested URI: " + request.getRequestURI()+NEW_LINE);
  msg.write("Requested Query String: " + request.getQueryString()+NEW_LINE);
  msg.write("Request method: "+request.getMethod()+NEW_LINE);
  try {
   if (request.getReader() != null) {
    msg.write("Request body: "+ request.getReader().readLine()+NEW_LINE);
    request.getReader().close();
   }
  } catch (IOException e) {
      e.printStrackTrace();
  } catch(IllegalStateException e) {
      e.printStrackTrace();
  }
  </code></pre>
  
  <p>Now it always throws an IllegalStateException, when reader is not null. How could I "revert" reader or how any other way to read the request body?</p>
  
  <p><strong>EDIT</strong>
  Exception: getInputStream() has already been called for this request</p>