1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *  http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package javax.servlet;
21  
22  
23  /**
24   * Defines a general exception a servlet can throw when it
25   * encounters difficulty.
26   *
27   * @author 	Various
28   * @version 	$Version$
29   */
30  public class ServletException extends Exception {
31  
32      /**
33       * Constructs a new servlet exception.
34       */
35      public ServletException() {
36          super();
37      }
38  
39      /**
40       * Constructs a new servlet exception with the
41       * specified message. The message can be written 
42       * to the server log and/or displayed for the user. 
43       *
44       * @param message 		a <code>String</code> 
45       *				specifying the text of 
46       *				the exception message
47       */
48      public ServletException(String message) {
49          super(message);
50      }
51  
52      /**
53       * Constructs a new servlet exception when the servlet 
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       * @param message 		a <code>String</code> containing 
59       *				the text of the exception message
60       *
61       * @param rootCause		the <code>Throwable</code> exception 
62       *				that interfered with the servlet's
63       *				normal operation, making this servlet
64       *				exception necessary
65       */
66      public ServletException(String message, Throwable rootCause) {
67          super(message, rootCause);
68      }
69  
70      /**
71       * Constructs a new servlet exception when the servlet 
72       * needs to throw an exception and include a message
73       * about the "root cause" exception that interfered with its
74       * normal operation.  The exception's message is based on the localized
75       * message of the underlying exception.
76       *
77       * <p>This method calls the <code>getLocalizedMessage</code> method
78       * on the <code>Throwable</code> exception to get a localized exception
79       * message. When subclassing <code>ServletException</code>, 
80       * this method can be overridden to create an exception message 
81       * designed for a specific locale.
82       *
83       * @param rootCause 	the <code>Throwable</code> exception
84       * 				that interfered with the servlet's
85       *				normal operation, making the servlet exception
86       *				necessary
87       */
88      public ServletException(Throwable rootCause) {
89          super(rootCause);
90      }
91  
92      /**
93       * Returns the exception that caused this servlet exception.
94       *
95       * @return			the <code>Throwable</code> 
96       *				that caused this servlet exception
97       */
98      public Throwable getRootCause() {
99          return getCause();
100     }
101 }