GeeCON Prague 2014*
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


JavaRanch » Java Forums » Java » JSP
Bookmark "errorPage doesn Watch "errorPage doesn New topic
Author

errorPage doesn't got to new page

Bruno Collins
Greenhorn

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
Greenhorn

Joined: Nov 30, 2001
Posts: 19
Error page looks like this:
<%@ page contentType="text/html" %>
<%@ page isErrorPage="true" %>
<html>
<link rel="stylesheet" type="text/css" href="../monstyle.css">
<h1>Sorry! an error has occured.</h1>
<blockquote>
Error message:<%= exception.getMessage() %><br>
Java exception:<%= exception.toString() %><br>
JSP requested:<%=request.getServerName()+request.getRequestURI() %><br>
</blockquote>
<% System.out.println("jsp_error_page: Error in JSP: " + request.getServerName()
+ request.getRequestURI() + ". Exception was: "+exception.toString()); %>
<h2>Please contact support.</h2>
</html>
Page creating the error:
<%@ page contentType="text/html" %>
<%@ page errorPage="/MonError.jsp" %>
<%@ page import="java.util.*" %>
<html>
<link rel="stylesheet" type="text/css" href="../monstyle.css">
<body>
<h2>Group List</h2>
<table cellpadding="0" cellspacing="0">
<tr>
<th>Group Code</th>
<th>Group Description</th>
<th>Edit</th>
<th>Delete</th>
<th>Copy</th>
</tr>
<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>
<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>
<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>
<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>
</tr>
<%
if (rowStyle=="tr1"){
rowStyle = "tr2";
}
else {
rowStyle = "tr1";
}
}
<%
if (true)
throw new Exception("This is my test"); // test error page
%>
%>
</table>
<p></p>
<a href="MonGroupMaint?mode=add">Add New User</a>
</body>
<html>
The error page appears in a cell of the page's table.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
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.
Bill
Bruno Collins
Greenhorn

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