• 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

buffer + page directive

 
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi i have the following code.

<%-- The size of file parul.txt is <200kb. Then why the exception --%>

<%@ page buffer="200kb"
autoFlush="false"
import="java.io.*"
errorPage="errorPage.jsp"
%>

<%

try{

FileReader dis = new FileReader("C:\\Tomcat5\\webapps\\scwcd\\HFSJ\\chap08\\parul.txt");
int i=dis.read();

while(i!=-1){
out.print(i);
i=dis.read();
}
}catch(Exception e){
out.println("ex:"+e.toString());
}


%>

Here the size of parul.txt is less than 200kb(buffer size). I am getting java.io.IOException: Error: JSP Buffer overflow.

Can some pls explain the reason of exception.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried the page using setting AutoFlush to true ? from the JSP spec-

"Specifies whether the buffered output should be flushed
automatically (true value) when the buffer is filled, or
whether an exception should be raised (false value) to
indicate buffer overflow." pg.1-47

I know you said your text file is less than 200K, so it shouldn't have filled up the 200kb buffer. How about different buffer sizes or turning the buffer off? maybe it raises an exception anyway when the jsp output ends to flag that there still is data in the buffer that has not been flushed...
 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes i have tried with autoFlush="true". It works fine . What i am trying to ask is that although the file size is less than the size of buffer, why is buffer overflow exception is happening.
 
reply
    Bookmark Topic Watch Topic
  • New Topic