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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package javax.servlet;
20 * Defines a general exception a servlet can throw when it encounters
23 public class ServletException extends Exception {
25 private static final long serialVersionUID = 1L;
28 * Constructs a new servlet exception.
30 public ServletException() {
35 * Constructs a new servlet exception with the specified message. The
36 * message can be written to the server log and/or displayed for the user.
39 * a <code>String</code> specifying the text of the exception
42 public ServletException(String message) {
47 * Constructs a new servlet exception when the servlet needs to throw an
48 * exception and include a message about the "root cause" exception that
49 * interfered with its normal operation, including a description message.
52 * a <code>String</code> containing the text of the exception
55 * the <code>Throwable</code> exception that interfered with the
56 * servlet's normal operation, making this servlet exception
59 public ServletException(String message, Throwable rootCause) {
60 super(message, rootCause);
64 * Constructs a new servlet exception when the servlet needs to throw an
65 * exception and include a message about the "root cause" exception that
66 * interfered with its normal operation. The exception's message is based on
67 * the localized message of the underlying exception.
69 * This method calls the <code>getLocalizedMessage</code> method on the
70 * <code>Throwable</code> exception to get a localized exception message.
71 * When subclassing <code>ServletException</code>, this method can be
72 * overridden to create an exception message designed for a specific locale.
75 * the <code>Throwable</code> exception that interfered with the
76 * servlet's normal operation, making the servlet exception
79 public ServletException(Throwable rootCause) {
84 * Returns the exception that caused this servlet exception.
86 * @return the <code>Throwable</code> that caused this servlet exception
88 public Throwable getRootCause() {