DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=27566>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=27566

POST paremeters lost after calling request.getReader()

           Summary: POST paremeters lost after calling request.getReader()
           Product: Tomcat 5
           Version: 5.0.19
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Catalina
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The following simple Servlet should display data sent with a POST request:

public class TestServlet
extends HttpServlet {
    // ---------------------------------------------------------- Public methods
    public void init() throws ServletException {
    }


    public void doPost(final HttpServletRequest  request ,
                      final HttpServletResponse response)
    throws ServletException, IOException {

        Reader r = request.getReader();

        String key;
        for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
            key = (String)e.nextElement();
            System.out.println(key);
        }
    }

}

Testing it with the following form
<html>
<body>
<head>
<title>Request Parameters Example</title>
</head>
<body bgcolor="white">
<a href="../reqparams.html">
<img src="../images/code.gif" height=24 width=24 align=right border=0 alt="view
code"></a>
<a href="../index.html">
<img src="../images/return.gif" height=24 width=24 align=right border=0
alt="return"></a>
<h3>Request Parameters Example</h3>
Parameters in this request:<br>
No Parameters, Please enter some
<p>

<form action="test" method=POST>
First Name:
<input type=text size=20 name=firstname>
<br>
Last Name:
<input type=text size=20 name=lastname>
<br>
<input type=submit>
</form>
</body>

shows that no parameters are detected.
Moving getReader() after the for loop, works around the problem.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to