001:
002: /*
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
004: *
005: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
006: *
007: * Portions Copyright Apache Software Foundation.
008: *
009: * The contents of this file are subject to the terms of either the GNU
010: * General Public License Version 2 only ("GPL") or the Common Development
011: * and Distribution License("CDDL") (collectively, the "License"). You
012: * may not use this file except in compliance with the License. You can obtain
013: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
014: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
015: * language governing permissions and limitations under the License.
016: *
017: * When distributing the software, include this License Header Notice in each
018: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
019: * Sun designates this particular file as subject to the "Classpath" exception
020: * as provided by Sun in the GPL Version 2 section of the License file that
021: * accompanied this code. If applicable, add the following below the License
022: * Header, with the fields enclosed by brackets [] replaced by your own
023: * identifying information: "Portions Copyrighted [year]
024: * [name of copyright owner]"
025: *
026: * Contributor(s):
027: *
028: * If you wish your version of this file to be governed by only the CDDL or
029: * only the GPL Version 2, indicate your decision by adding "[Contributor]
030: * elects to include this software in this distribution under the [CDDL or GPL
031: * Version 2] license." If you don't indicate a single choice of license, a
032: * recipient has the option to distribute your version of this file under
033: * either the CDDL, the GPL Version 2 or to extend the choice of license to
034: * its licensees as provided above. However, if you add GPL Version 2 code
035: * and therefore, elected the GPL Version 2 license, then the option applies
036: * only if the new code is made subject to such option by the copyright
037: * holder.
038: */
039:
040: package javax.servlet;
041:
042: /**
043: * Defines a general exception a servlet can throw when it
044: * encounters difficulty.
045: *
046: * @author Various
047: */
048:
049: public class ServletException extends Exception {
050:
051: private Throwable rootCause;
052:
053: /**
054: * Constructs a new servlet exception.
055: *
056: */
057:
058: public ServletException() {
059: super ();
060: }
061:
062: /**
063: * Constructs a new servlet exception with the
064: * specified message. The message can be written
065: * to the server log and/or displayed for the user.
066: *
067: * @param message a <code>String</code>
068: * specifying the text of
069: * the exception message
070: *
071: */
072:
073: public ServletException(String message) {
074: super (message);
075: }
076:
077: /**
078: * Constructs a new servlet exception when the servlet
079: * needs to throw an exception and include a message
080: * about the "root cause" exception that interfered with its
081: * normal operation, including a description message.
082: *
083: *
084: * @param message a <code>String</code> containing
085: * the text of the exception message
086: *
087: * @param rootCause the <code>Throwable</code> exception
088: * that interfered with the servlet's
089: * normal operation, making this servlet
090: * exception necessary
091: *
092: */
093:
094: public ServletException(String message, Throwable rootCause) {
095: super (message, rootCause);
096: this .rootCause = rootCause;
097: }
098:
099: /**
100: * Constructs a new servlet exception when the servlet
101: * needs to throw an exception and include a message
102: * about the "root cause" exception that interfered with its
103: * normal operation. The exception's message is based on the localized
104: * message of the underlying exception.
105: *
106: * <p>This method calls the <code>getLocalizedMessage</code> method
107: * on the <code>Throwable</code> exception to get a localized exception
108: * message. When subclassing <code>ServletException</code>,
109: * this method can be overridden to create an exception message
110: * designed for a specific locale.
111: *
112: * @param rootCause the <code>Throwable</code> exception
113: * that interfered with the servlet's
114: * normal operation, making the servlet exception
115: * necessary
116: *
117: */
118:
119: public ServletException(Throwable rootCause) {
120: super (rootCause);
121: this .rootCause = rootCause;
122: }
123:
124: /**
125: * Returns the exception that caused this servlet exception.
126: *
127: *
128: * @return the <code>Throwable</code>
129: * that caused this servlet exception
130: *
131: */
132:
133: public Throwable getRootCause() {
134: return rootCause;
135: }
136: }
|