my dog learned polymorphism
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

buffer + page directive

Naresh Chaurasia
Ranch Hand

Joined: May 18, 2005
Posts: 361
hi i have the following code.

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

<%@ page buffer="200kb"



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

}catch(Exception e){


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

Can some pls explain the reason of exception.

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

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: 361
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:
subject: buffer + page directive
It's not a secret anymore!