What are you posting? This code works for me:

public class TestPostServlet extends HttpServlet {

    protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
        InputStream in = request.getInputStream();

        int size = in.available();
        byte[] body = new byte[size];
        int status = in.read(body);
        in.close();

        response.getWriter().println("Status of read: " + status + " Size: "
+ size);
        response.getWriter().println("Got your post: " + new String(body));

    }
}

What mechanism are you using to POST to your application? Is it a browser
form or a custom client?

On Sat, Nov 21, 2009 at 12:37 PM, Bourke Floyd IV <[email protected]> wrote:

> //This was working before I overhauled the authentication of my app
> //I'm trying to store the body of a Http POST as Text, I also plan on
> doing a Blob version
> //The maxLength is returning the correct size, but the read is
> returning -1 instead of properly
> //updating the body byte array
>
> //...
>
> InputStream httpIn = req.getInputStream();
> byte[] body = new byte[httpIn.available()];
> httpIn.read(body);
>
> Text myPostBody = new Text(new String(body)); //wasteful maybe? but
> should work
>
> //...
>
> //My old code was roughly the same
>
> //...
>
> int maxLength = req.getContentLength();
> byte[] body = new byte[maxLength];
>
> InputStream httpIn = req.getInputStream();
> httpIn.read(body, 0, maxLength);
>
> String  myPostBody = new String(body); //wasteful maybe? but should
> work
>
> //...
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=.
>
>
>


-- 
Ikai Lan
Developer Programs Engineer, Google App Engine

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=.


Reply via email to