6 Replies Latest reply on Jul 17, 2009 2:34 PM by daniele campanini

    request.getInputstream() or getReader always empty

    Serkan Eskici Novice


      Im trying to read XML from the HttpServletRequest, which is sent by the client, but when I try ro read it from the inputstream by calling request.getInputStream or request.getReader I always get an empty stream.

      Is this because the SeamFilter reads this stream and than closes it before I call my method ?

      This is how my code and configurations look like:

      public class XmlReader extends AbstractBean
          public void readXML()
                  HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
                  log.info(format("content type: %s", req.getContentType()));
                  BufferedReader in = req.getReader();
                  StringBuilder sb = new StringBuilder();
                  String line = null;
                  while ((line = in.readLine()) != null)
                  log.debug(format("Web page content: \n%s", sb));


       <page view-id="/xmlreader.xhtml" action="#{xmlReader.readXML()}">
              <rewrite pattern="/xmlreader"/>