Servlet getInputStream fail with GAE 1.5!!

131 views
Skip to first unread message

Marc Hacker

unread,
Sep 14, 2011, 11:10:45 AM9/14/11
to Google App Engine
HttpServletRequest request.getInputStream() works great in 1.4 but
fails in 1.5. This is a pretty basic problem.

Here is some test code:

public void doPost(HttpServletRequest request, HttpServletResponse
response) {
try {
response.setContentType("text/plain; charset=utf-8");
byte [] b = new byte [100000]; // reusable buffer for reading bytes
int len = request.getInputStream().read(b);
response.getWriter().println("Number of bytes = " + len);
} catch (IOException e) {
e.printStackTrace();
}
}

Then post some data with:

<form name="input" action="ADDRESS OF SERVLET" method="POST">
<input type="text" name="method" value="Test data" />
<input type="submit" value="Test /api/user" />
</form>

With 1.4 you get the length of the data, with 1.5.2 I get -1 !!

Also see http://stackoverflow.com/questions/5348298/servlets-request-getinputstream-request-getreader-not-working-struts2
Reply all
Reply to author
Forward
0 new messages