001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *  http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    
020    package javax.servlet;
021    
022    
023    /**
024     * Defines a general exception a servlet can throw when it
025     * encounters difficulty.
026     *
027     * @author      Various
028     * @version     $Version$
029     */
030    public class ServletException extends Exception {
031    
032        /**
033         * Constructs a new servlet exception.
034         */
035        public ServletException() {
036            super();
037        }
038    
039        /**
040         * Constructs a new servlet exception with the
041         * specified message. The message can be written 
042         * to the server log and/or displayed for the user. 
043         *
044         * @param message           a <code>String</code> 
045         *                          specifying the text of 
046         *                          the exception message
047         */
048        public ServletException(String message) {
049            super(message);
050        }
051    
052        /**
053         * Constructs a new servlet exception when the servlet 
054         * needs to throw an exception and include a message 
055         * about the "root cause" exception that interfered with its 
056         * normal operation, including a description message.
057         *
058         * @param message           a <code>String</code> containing 
059         *                          the text of the exception message
060         *
061         * @param rootCause         the <code>Throwable</code> exception 
062         *                          that interfered with the servlet's
063         *                          normal operation, making this servlet
064         *                          exception necessary
065         */
066        public ServletException(String message, Throwable rootCause) {
067            super(message, rootCause);
068        }
069    
070        /**
071         * Constructs a new servlet exception when the servlet 
072         * needs to throw an exception and include a message
073         * about the "root cause" exception that interfered with its
074         * normal operation.  The exception's message is based on the localized
075         * message of the underlying exception.
076         *
077         * <p>This method calls the <code>getLocalizedMessage</code> method
078         * on the <code>Throwable</code> exception to get a localized exception
079         * message. When subclassing <code>ServletException</code>, 
080         * this method can be overridden to create an exception message 
081         * designed for a specific locale.
082         *
083         * @param rootCause         the <code>Throwable</code> exception
084         *                          that interfered with the servlet's
085         *                          normal operation, making the servlet exception
086         *                          necessary
087         */
088        public ServletException(Throwable rootCause) {
089            super(rootCause);
090        }
091    
092        /**
093         * Returns the exception that caused this servlet exception.
094         *
095         * @return                  the <code>Throwable</code> 
096         *                          that caused this servlet exception
097         */
098        public Throwable getRootCause() {
099            return getCause();
100        }
101    }