• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ServletInputStream class error

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
if i am trying to read readLine method of ServletInputStream twice . It is throwing IOException.
What might be cause of the error. I am using jsp request object i.e request.getInputStream to get ServletInputStream class.

public int readLine(byte[] b, int off, int len) throws IOException;
Thanks
Monzy
 
MONZY THARIAN
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The method public int readLine(byte[] b, int off, int len) throws IOException;
is returning -1 when i am trying to read it for the secomd time. First time it is giving returning proper value.

Kindly suggest .
Thanks in advance.
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
When it returns -1, this means there is no more data to read, as with all io streams. You need to construct your read loop with this as the terminating condition, so that you don't try to read from it when there is no more data available.
Michael
reply
    Bookmark Topic Watch Topic
  • New Topic