Meaningless Drivel is fun!*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes buffer + page directive Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "buffer + page directive" Watch "buffer + page directive" New topic
Author

buffer + page directive

Naresh Chaurasia
Ranch Hand

Joined: May 18, 2005
Posts: 356
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.


SCJP 1.4, SCWCD1.4, OCA(1Z0-007)
Jeremy Leong
Greenhorn

Joined: May 25, 2004
Posts: 5
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

Joined: May 18, 2005
Posts: 356
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: buffer + page directive
 
Similar Threads
buffer overflow exception
Difference bwtween jsp:forward and RequestDispatcher forward.
How do you link 8k with 12264 ?
about file separator
when loading jsp page.........