<%@ page isErrorPage="true"%> <%@ page import="java.util.*" %> <%@ page import="java.io.*" %> Error Page <%-- The exception.getMessage() statement returns the name of the error --%> The error is: <%=exception.getMessage()%>

<%-- The exception.printStackTrace() statement returns the stack, which is all the classes in the execution path. --%> The stack trace is:

<% PrintWriter myOut = new PrintWriter(out); exception.printStackTrace(myOut); %>


Here are the attributes of the application: <%-- The following for loop presents all the attributes stored in the implicit application object. --%> <% Enumeration loop = application.getAttributeNames(); while (loop.hasMoreElements()){ String name = (String) loop.nextElement(); %>
<%=name%>: <%=application.getAttribute( name).toString()%> <% } %>


Here are the attributes of the session: <%-- The following for loop presents all the attributes stored in the implicit session object. --%> <% loop = session.getAttributeNames(); while (loop.hasMoreElements()){ String name = (String) loop.nextElement(); %>
<%=name%>: <%=session.getAttribute( name).toString()%> <% } %>


Here are the attributes of the request: <%-- The following for loop presents all the attributes stored in the implicit request object. --%> <% loop = request.getAttributeNames(); while (loop.hasMoreElements()){ String name = (String) loop.nextElement(); %>
<%=name%>: <%=request.getAttribute( name).toString()%> <% } %>

Here are the parameters of the request: <%-- This block shows all the request parameters sent by the user. There are two loops because request attributes can have more than only value per name. The out loop steps through all the parameters and then inner loop steps through all the values for each parameter. --%> <% loop = request.getParameterNames(); while (loop.hasMoreElements()){ String name = (String) loop.nextElement(); for(int index = 0; index < request.getParameterValues(name).length; index++){ %>
<%=name%>: <%=request.getParameterValues( name)[index]%> <% } } %> <%-- the implit page attributes cannot be displayed because as soon as the page that throws an error is out of scope, the attributes are no longer available --%>