1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18
19
20
21
22
23
24 package javax.servlet.jsp;
25
26 /**
27 * A generic exception known to the JSP engine; uncaught
28 * JspExceptions will result in an invocation of the errorpage
29 * machinery.
30 */
31
32 public class JspException extends Exception {
33
34 private Throwable rootCause;
35
36
37 /**
38 * Construct a JspException.
39 */
40 public JspException() {
41 }
42
43
44 /**
45 * Constructs a new JSP exception with the
46 * specified message. The message can be written
47 * to the server log and/or displayed for the user.
48 *
49 * @param msg a <code>String</code>
50 * specifying the text of
51 * the exception message
52 *
53 */
54 public JspException(String msg) {
55 super(msg);
56 }
57
58
59 /**
60 * Constructs a new JSP exception when the JSP
61 * needs to throw an exception and include a message
62 * about the "root cause" exception that interfered with its
63 * normal operation, including a description message.
64 *
65 *
66 * @param message a <code>String</code> containing
67 * the text of the exception message
68 *
69 * @param rootCause the <code>Throwable</code> exception
70 * that interfered with the servlet's
71 * normal operation, making this servlet
72 * exception necessary
73 *
74 */
75
76 public JspException(String message, Throwable rootCause) {
77 super(message);
78 this.rootCause = rootCause;
79 }
80
81
82 /**
83 * Constructs a new JSP exception when the JSP
84 * needs to throw an exception and include a message
85 * about the "root cause" exception that interfered with its
86 * normal operation. The exception's message is based on the localized
87 * message of the underlying exception.
88 *
89 * <p>This method calls the <code>getLocalizedMessage</code> method
90 * on the <code>Throwable</code> exception to get a localized exception
91 * message. When subclassing <code>JspException</code>,
92 * this method can be overridden to create an exception message
93 * designed for a specific locale.
94 *
95 * @param rootCause the <code>Throwable</code> exception
96 * that interfered with the JSP's
97 * normal operation, making the JSP exception
98 * necessary
99 *
100 */
101
102 public JspException(Throwable rootCause) {
103 super(rootCause.getLocalizedMessage());
104 this.rootCause = rootCause;
105 }
106
107
108 /**
109 * Returns the exception that caused this JSP exception.
110 *
111 *
112 * @return the <code>Throwable</code>
113 * that caused this JSP exception
114 *
115 */
116
117 public Throwable getRootCause() {
118 return rootCause;
119 }
120 }