Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

HttpServletRequest.getInputStream().read(byte[] ba)

843841Apr 18 2005 — edited Apr 21 2006
The code below does not work as I expect it to. The entire stream(request) content is not read into the array. The len and the len2 differ in size and the ba when printed displays only the first part of the text in the request, then blanks until len is reached. Does anyone have an idea what might be the problem? The problem occurs with lengts around 1000 bytes and larger. About half is cut off.

doPost(HttpServletRequest req, HttpServletResponse res)
{
        int len = req.getContentLength();
        InputStream is = req.getInputStream();

        byte[] ba = new byte[8192];
        int len2 = is.read(ba, 0, len);
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 19 2006
Added on Apr 18 2005
11 comments
3,432 views