KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > servlet > jsp > JspException


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. 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 package javax.servlet.jsp;
18
19 /**
20  * A generic exception known to the JSP engine; uncaught
21  * JspExceptions will result in an invocation of the errorpage
22  * machinery.
23  */

24
25 public class JspException extends Exception JavaDoc {
26
27     private Throwable JavaDoc rootCause;
28
29
30     /**
31      * Construct a JspException.
32      */

33     public JspException() {
34     }
35
36
37     /**
38      * Constructs a new JSP exception with the
39      * specified message. The message can be written
40      * to the server log and/or displayed for the user.
41      *
42      * @param msg a <code>String</code>
43      * specifying the text of
44      * the exception message
45      *
46      */

47     public JspException(String JavaDoc msg) {
48     super(msg);
49     }
50
51
52     /**
53      * Constructs a new JSP exception when the JSP
54      * needs to throw an exception and include a message
55      * about the "root cause" exception that interfered with its
56      * normal operation, including a description message.
57      *
58      *
59      * @param message a <code>String</code> containing
60      * the text of the exception message
61      *
62      * @param rootCause the <code>Throwable</code> exception
63      * that interfered with the servlet's
64      * normal operation, making this servlet
65      * exception necessary
66      *
67      */

68     
69     public JspException(String JavaDoc message, Throwable JavaDoc rootCause) {
70     super(message);
71     this.rootCause = rootCause;
72     }
73
74
75     /**
76      * Constructs a new JSP exception when the JSP
77      * needs to throw an exception and include a message
78      * about the "root cause" exception that interfered with its
79      * normal operation. The exception's message is based on the localized
80      * message of the underlying exception.
81      *
82      * <p>This method calls the <code>getLocalizedMessage</code> method
83      * on the <code>Throwable</code> exception to get a localized exception
84      * message. When subclassing <code>JspException</code>,
85      * this method can be overridden to create an exception message
86      * designed for a specific locale.
87      *
88      * @param rootCause the <code>Throwable</code> exception
89      * that interfered with the JSP's
90      * normal operation, making the JSP exception
91      * necessary
92      *
93      */

94
95     public JspException(Throwable JavaDoc rootCause) {
96     super(rootCause.getLocalizedMessage());
97     this.rootCause = rootCause;
98     }
99
100     
101     /**
102      * Returns the exception that caused this JSP exception.
103      *
104      *
105      * @return the <code>Throwable</code>
106      * that caused this JSP exception
107      *
108      */

109     
110     public Throwable JavaDoc getRootCause() {
111     return rootCause;
112     }
113 }
114
Popular Tags