File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

buffer + page directive

 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Jeremy Leong
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic