Datasheet
Patrick c01.tex V3 - 09/18/2009 12:15pm Page 14
Chapter 1: Building Web Applications in WebLogic
Listing 1-1: ErrorPage.jsp.
(continued)
<hr>
<h3>Requested URL</h3>
<pre>
<%= HttpUtils.getRequestURL(request) %>
</pre>
<h3>Request Parameters</h3>
<pre>
<%
Enumeration params = request.getParameterNames();
while(params.hasMoreElements()){
String key = (String)params.nextElement();
String[] paramValues = request.getParameterValues(key);
for(int i = 0; i < paramValues.length; i++) {
out.println(key + " : " + paramValues[i]);
}
}
%>
</pre>
<h3>Request Attributes</h3>
<pre>
...
</pre>
<h3>Request Information</h3>
<pre>
...
</pre>
<h3>Request Headers</h3>
<pre>
...
</pre>
Second, place a
<%@ page errorPage="
...
"%>
directive on all JSP pages in the application specifying
the location of this error JSP page. Listing 1-2 presents a simple example JSP page that declares the error
page explicitly. Normally, you would do this through a common include file shared by all pages rather
than including the directive on every page.
Listing 1-2: ErrorCreator.jsp.
<%@ page errorPage="ErrorPage.jsp" %>
<html>
<head></head>
<body>
<!-- Do something sure to cause problems -->
<% String s = null; %>
The string length is: <%= s.length() %><p>
</body>
</html>
14