This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes errorPage doesn't got to new page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "errorPage doesn Watch "errorPage doesn New topic

errorPage doesn't got to new page

Bruno Collins

Joined: Nov 30, 2001
Posts: 19
I have a JSP page that has an error page defined. This works, however depending upon where the error occurs in the jsp page all of the page up to the point of the error is also displayed. If I induce an error at the top of the page just the error page is visible. If I induce an error somewhere later in the page say in a table cell the contents of the error page appears here with the rest of the page. It is as if the error page is an include.
Steffen Foldager
Ranch Hand

Joined: Mar 22, 2001
Posts: 58
Could you submit some code as well?

Steffen Foldager<p>Sun Certified Java Programmer<br />Sun Certified Web Component Developer
Bruno Collins

Joined: Nov 30, 2001
Posts: 19
Error page looks like this:
<%@ page contentType="text/html" %>
<%@ page isErrorPage="true" %>
<link rel="stylesheet" type="text/css" href="../monstyle.css">
<h1>Sorry! an error has occured.</h1>
Error message:<%= exception.getMessage() %><br>
Java exception:<%= exception.toString() %><br>
JSP requested:<%=request.getServerName()+request.getRequestURI() %><br>
<% System.out.println("jsp_error_page: Error in JSP: " + request.getServerName()
+ request.getRequestURI() + ". Exception was: "+exception.toString()); %>
<h2>Please contact support.</h2>
Page creating the error:
<%@ page contentType="text/html" %>
<%@ page errorPage="/MonError.jsp" %>
<%@ page import="java.util.*" %>
<link rel="stylesheet" type="text/css" href="../monstyle.css">
<h2>Group List</h2>
<table cellpadding="0" cellspacing="0">
<th>Group Code</th>
<th>Group Description</th>
<jsp:useBean id="mglb" scope="request" class="com.primur.monitor.MonGroupListBean"/>
String rowStyle = "tr1";
Vector grouplist = (Vector)request.getAttribute("grouplist") ;
for (Enumeration e = grouplist.elements() ; e.hasMoreElements() {
mglb =(com.primur.monitor.MonGroupListBean)e.nextElement();
<tr class="<%=rowStyle %>">
<td> <a title="View" href="MonGroupMaint?mode=view&id=<%= mglb.getGrgrpc() %>">
<%= mglb.getGrgrpc() %></td>
<td><%= mglb.getGrdesc() %></td>
<p align="center">
<a href="MonGroupMaint?mode=edit&id=<%= mglb.getGrgrpc() %>">
<img border="0" src="../edt.gif" width="22" height="20" alt="Edit"></a></td>
<p align="center">
<a href="MonGroupMaint?mode=delete&id=<%= mglb.getGrgrpc() %>">
<img border="0" src="../del.gif" width="22" height="20" alt="Delete"></a></td>
<p align="center">
<a href="MonGroupMaint?mode=copy&id=<%= mglb.getGrgrpc() %>">
<img border="0" src="../cpy.gif" width="22" height="20" alt="Copy"></a></td>
if (rowStyle=="tr1"){
rowStyle = "tr2";
else {
rowStyle = "tr1";
if (true)
throw new Exception("This is my test"); // test error page
<a href="MonGroupMaint?mode=add">Add New User</a>
The error page appears in a cell of the page's table.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12759
That is because at least one bufferload has already been flushed when the error occurs. You might try increasing the buffer size in the page directive.
Bruno Collins

Joined: Nov 30, 2001
Posts: 19
Thanks I will give it a try.
Don't get me started about those stupid light bulbs.
subject: errorPage doesn't got to new page
Similar Threads
Servlet vs JSP
Action Form Problem
Why to use DTD if the schema is more flexible/powerful?
JSTL exception handling