0 Replies Latest reply on Feb 19, 2008 9:55 AM by mladen.dryankov

    HttpServletRequest.getInputStream.read is broken

    mladen.dryankov

      Hi All,

      Can anyone help me for this issue?
      For this scenario I am using a simple HttpServlet

       protected void doGet(HttpServletRequest req, HttpServletResponse res)
       throws ServletException, IOException {
       InputStream is = req.getInputStream();
       String line = null;
       BufferedReader reader = new BufferedReader(new InputStreamReader(is));
       try {
       while ((line = reader.readLine()) != null) {
       System.out.println(line);
       }
       } catch (Exception e) {
       e.printStackTrace();
       }
       }
      
      


      and simple client from the client side:
       public static void main(String[] args) {
       try {
       Socket s = new Socket();
      
       s.connect(new InetSocketAddress("10.0.0.10", 8080));
       s.setSoTimeout(9999999);
       s.setKeepAlive(true);
       s.setTcpNoDelay(true);
       PrintWriter ps = new PrintWriter(s.getOutputStream(), false);
       ps.println("GET http://10.0.20.10:8080/testservlet/mservlet\r\n");
      
       ps.println("Test line 1");
       ps.println("Test line 2");
       ps.println("Test line 3");
       ps.flush();
       } catch (Exception e) {
       e.printStackTrace();
       }
      
       }
      


      The problem is that the InputStream in the Servlet above doesn't read anything.
      Any aidea?

      P.S. This behavior can reproduce with all Jboss versions bigger than 4.0.3 (4.0.4, 4.0.5, 4.2.2 and 5.0) and Tomcat 5.5.15+ and ver 6... Jboss Web Server as well.

      Best regards
      Mladen