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
<error-page> <exception-type>java.lang.Exception</exception-type> <location>/error/errorPage.jsp</location> </error-page>
The errorPage.jsp has page attribute as
<%@ page isErrorPage="true" %>
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.
<% String sstr = null; sstr.length();%>
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[i] 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 autoFlush="false" 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 autoFlush="false" 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.