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

    request.getInputstream() or getReader always empty

    serkan.s.eskici.online.nl

      Hi.


      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:


      @Scope(ScopeType.EVENT)
      @Name("xmlReader")
      public class XmlReader extends AbstractBean
      {
          public void readXML()
          {
              try
              {
                  HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
                  log.info(req.getRequestURL());
                  log.info(format("content type: %s", req.getContentType()));
      
                  BufferedReader in = req.getReader();
                  StringBuilder sb = new StringBuilder();
                  String line = null;
      
                  while ((line = in.readLine()) != null)
                      sb.append(line);
      
                  in.close();
                  log.debug(format("Web page content: \n%s", sb));
              }  
      



      pages.xml:


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