|
para generar paginas de error de jsp es necesario crear una pagina que despliegue el error y configurarla en el archivo web.xml.
Listado 1: web.xml (extracto)
...
</welcome-file-list>
<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/error.jsp</location>
</error-page>
<taglib>
...
Listado 2: error.jsp
<html>
<head>
<%@page language="java" isErrorPage="true"%>
<title>Error</title>
<link rel="stylesheet"
href="<%=request.getContextPath()%>/styles.css" type="text/css">
<script>
function invertNext(node, name){
do {
node=node.nextSibling;
} while ((node!=null) && ( node.nodeName!=name));
if (node!=null) {
if (node.style.display=="none")
node.style.display="";
else
node.style.display="none";
}
}
</script>
</head>
<body leftmargin="2" topmargin="2">
<body>
<table width="90%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td colspan="3" height="20" align="center"> </td>
</tr>
<tr>
<td width="10%"><img
src="<%=request.getContextPath()%>/error.gif" width="50"
height="50"></td>
<td width="80%" align="center"><font color="#cc0000" size="+2">Ha
ocurrido un error!</font></td>
</tr>
<tr>
<td colspan="2" align="center"><!-- Excepcion recibida--> <font
color="#333366" size="+1"><%=exception.getMessage()%></font><br>
</td>
</tr>
<tr>
<td colspan="2" align="left"><!-- Boton para mostrar Pila -->
<p> </p>
<p> </p>
La lista de condiciones de excepcion es:
<!-- Volcados de Pila -->
<div id="exceptionList" style="display: "><%!String format(Throwable t) {
if (t == null)
return "(Null Exception)";
String n = t.getClass().getName();
int i = n.lastIndexOf('.');
if (i > 0)
n = n.substring(i + 1);
return "[" + n + "] " + t.getMessage();
}
%> <%out.println("<ol>");
Throwable t = exception;
while (t != null) {
out.println("<li>" + format(t));%>
<input type="checkbox" onClick="invertNext(this, 'DIV')"><br>
<div style="display: none">
<table border="1" width="100">
<tr>
<td><pre>
<%java.io.StringWriter sw = new java.io.StringWriter();
java.io.PrintWriter pw = new java.io.PrintWriter(sw);
t.printStackTrace(pw);
out.println(sw);%>
</pre></td>
</tr>
</table>
</div>
<%Throwable next = null;
if (t instanceof java.sql.SQLException) {
next = ((java.sql.SQLException) t).getNextException();
} else if (t instanceof javax.servlet.ServletException) {
next = ((javax.servlet.ServletException) t).getRootCause();
} else if (t instanceof com.bh.talon.ApplicationException) {
next = ((com.bh.talon.ApplicationException) t).getRootException();
}
t = next;
}
out.println("</ul>");
%></div>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<hr>
<div align="center"><%=new java.util.Date()%></div>
</td>
</tr>
</table>
</body>
</html>
|