This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSP and the fly likes JSP Problems: Exception Handling, buffer, autoFlush Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP Problems: Exception Handling, buffer, autoFlush" Watch "JSP Problems: Exception Handling, buffer, autoFlush" New topic
Author

JSP Problems: Exception Handling, buffer, autoFlush

Abhishek Chaudhari
Greenhorn

Joined: Feb 09, 2005
Posts: 11
Hi,
We have a web application implemented using Webwork 2.1 & Hibernate 2.1 deployed on Tomcat 4.1.29.
We have set the error page in web.xml as

The errorPage.jsp has page attribute as

This error page is used to handle the exception on expenses.jsp.
We are checking log for exceptions thrown.
For testing purpose, I have written following code in the expenses.jsp to throw NullPointerException.

Now when NullPointerException is thrown on jsp at the middle, some part of the jsp gets displayed & the error page is not displayed OR sometimes the error page appears after the rendered part of the expenses.jsp.
I think this is because on jsp pages, we have autoFlush="true" by default & hence as soon as the buffer size(which is 8kb by default) is reached the response is flushed.
Hence I tried out setting autoFlush="false" on the expenses.jsp. Now the error page is displayed as desired but with different exception. The exception thrown is org.apache.jasper.JasperException: Error: JSP Buffer overflow followed by java.lang.NullPointerException which (buffer overflow) should not happen.
After that I increased the buffer size to 32kb for expenses.jsp. Now the exceptions thrown are org.apache.jasper.JasperException: followed by java.lang.NullPointerException which is desired.
Now we are thinking of applying the same strategy for all the pages.
The questions are:
  • What should be the buffer size? 32kb won't be sufficient for pages with a lot of data.
  • For applying the same thing to all pages, we need to put <%@ page buffer="32kb"%> to all the pages. But the existing code has a lot of such jsps which need an error page to be added.
  • Is there any better way, solve this problem rather than adding <%@ page buffer="32kb"%> to all the pages as we don't want to have minimal change to the existing code and we never know how much buffer size will be sufficient?

  • I've read somewhere that increasing buffer size may create problem for Tomcat.

    [ November 11, 2005: Message edited by: Abhishek Chaudhari ]
    [ November 15, 2005: Message edited by: Abhishek Chaudhari ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: JSP Problems: Exception Handling, buffer, autoFlush
     
    Similar Threads
    buffer attribute verses autoflush - confusion?
    buffer overflow exception
    buffer + page directive
    Is there a maximum size for a JSP?
    response.flushBuffer inside a JSP page not doing anything