SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 104 | Next

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"

java
package coreservlets;
/** Exception used to flag particularly onerous
programmer blunders. Used to illustrate the
exception-type web.xml element.
*/
public class DumbDeveloperException extends Exception {
public DumbDeveloperException() {
super("Duh. What was I *thinking*?");
}
Chapter 2 ?–  Controlling Web Application Behavior with web.xml 76
public static int dangerousComputation(int n)
throws DumbDeveloperException {
if (n < 5) {
return(n + 10);
} else {
throw(new DumbDeveloperException());
}
}
}
Listing 2.20 RiskyPage.jsp


Risky JSP Page

Risky Calculations


<%@ page import="coreservlets.*" %>
<% int n = ((int)(10 * Math.random())); %>

  • n: <%= n %>
  • dangerousComputation(n):
    <%= DumbDeveloperException.dangerousComputation(n) %>


Listing 2.21 DDE.jsp


Dumb

Dumb Developer


We're brain dead. Consider using our competitors.

Listing 2.19 DumbDeveloperException.java (continued)
2.9 Designating Pages to Handle Errors 77
Figure 2??“20 Fortuitous results of RiskyPage.jsp.
Figure 2??“21 Unlucky results of RiskyPage.jsp.
Listing 2.22 web.xml (Excerpt designating error pages for exceptions)


Pages:
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116