title: How to convert an HttpServletRequest to String?
body: <p>How can I convert an <code>HttpServletRequest</code> to <code>String</code>? I need to unmarshall the <code>HttpServletRequest</code> but when I try to, my program throws an exception.</p>
  
  <pre><code> javax.xml.bind.UnmarshalException
   - with linked exception:
  [java.io.IOException: Stream closed]
          at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:197)
          at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:168)
          at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
          at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:184)
          at com.orange.oapi.parser.XmlParsing.parse(XmlParsing.java:33)
  </code></pre>
  
  <p>I tried the following code to unmarshall the <code>HttpServletRequest</code>.</p>
  
  <pre><code>InputStreamReader is =
                  new InputStreamReader(request.getInputStream());
  InputStream isr = request.getInputStream();
  ServletInputStream req = request.getInputStream();
  </code></pre>
  
  <p>My parser method:</p>
  
  <pre><code>public root parse(InputStreamReader is) throws Exception {
          root mc = null;
          try {
              JAXBContext context = JAXBContext.newInstance(root.class);
              Unmarshaller um = context.createUnmarshaller();
              mc = (root) um.unmarshal(is);
          } catch (JAXBException je) {
              je.printStackTrace();
          }
          return mc;
      }
  </code></pre>