problem read ServletInputStream

Discussion in 'Java' started by AlexF, Dec 5, 2006.

  1. AlexF

    AlexF Guest

    Hi,

    I didn't find the answer at group content.
    May be anybody knows how to solve this problem?

    I use HTTPS connection and servlet receives XML to parse.

    With JDK1.4 was no problem with reading ServletInputStream:

    ServletInputStream inputStream = request.getInputStream();
    lw.info("After Get Input Stream.");
    ByteArrayOutputStream uploadBuffer = new
    ByteArrayOutputStream();

    int count;
    byte[] buff = new byte[2048];
    lw.info("Start reading from buffer");
    while ((count = inputStream.read(buff)) != -1) {
    uploadBuffer.write(buff, 0, count);
    }
    lw.info("End reading from buffer");
    inputStream.close();
    uploadBuffer.close();
    req = new String(uploadBuffer.toByteArray());

    The same code compiled with JDK1.5 returns empty request - at first
    read the return value is -1.
    I've tried all read(..) methods but without unsucceed.

    Please, help to solve the problem.
    AlexF, Dec 5, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Isaac
    Replies:
    0
    Views:
    2,444
    Isaac
    Jul 10, 2003
  2. Doug
    Replies:
    3
    Views:
    4,347
    Bruce Barker
    Nov 4, 2005
  3. Suresh
    Replies:
    0
    Views:
    493
    Suresh
    Sep 21, 2005
  4. Replies:
    3
    Views:
    514
    John W. Krahn
    Apr 7, 2006
  5. adblock

    Closing ServletInputStream

    adblock, Jan 30, 2008, in forum: Java
    Replies:
    7
    Views:
    1,599
Loading...

Share This Page