Save This Page
Home » glassfish-v2ur2-b04-src » javax » servlet » jsp » [javadoc | source]
    1   /*
    2    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    3    * 
    4    * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
    5    * 
    6    * Portions Copyright Apache Software Foundation.
    7    * 
    8    * The contents of this file are subject to the terms of either the GNU
    9    * General Public License Version 2 only ("GPL") or the Common Development
   10    * and Distribution License("CDDL") (collectively, the "License").  You
   11    * may not use this file except in compliance with the License. You can obtain
   12    * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
   13    * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
   14    * language governing permissions and limitations under the License.
   15    * 
   16    * When distributing the software, include this License Header Notice in each
   17    * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
   18    * Sun designates this particular file as subject to the "Classpath" exception
   19    * as provided by Sun in the GPL Version 2 section of the License file that
   20    * accompanied this code.  If applicable, add the following below the License
   21    * Header, with the fields enclosed by brackets [] replaced by your own
   22    * identifying information: "Portions Copyrighted [year]
   23    * [name of copyright owner]"
   24    * 
   25    * Contributor(s):
   26    * 
   27    * If you wish your version of this file to be governed by only the CDDL or
   28    * only the GPL Version 2, indicate your decision by adding "[Contributor]
   29    * elects to include this software in this distribution under the [CDDL or GPL
   30    * Version 2] license."  If you don't indicate a single choice of license, a
   31    * recipient has the option to distribute your version of this file under
   32    * either the CDDL, the GPL Version 2 or to extend the choice of license to
   33    * its licensees as provided above.  However, if you add GPL Version 2 code
   34    * and therefore, elected the GPL Version 2 license, then the option applies
   35    * only if the new code is made subject to such option by the copyright
   36    * holder.
   37    */
   38    
   39   package javax.servlet.jsp;
   40   
   41   /**
   42    * A generic exception known to the JSP engine; uncaught
   43    * JspExceptions will result in an invocation of the errorpage
   44    * machinery.
   45    */
   46   
   47   public class JspException extends Exception {
   48   
   49       private Throwable rootCause;
   50   
   51   
   52       /**
   53        * Construct a JspException.
   54        */
   55       public JspException() {
   56       }
   57   
   58   
   59       /**
   60        * Constructs a new JSP exception with the
   61        * specified message. The message can be written 
   62        * to the server log and/or displayed for the user. 
   63        *
   64        * @param msg 		a <code>String</code> 
   65        *				specifying the text of 
   66        *				the exception message
   67        *
   68        */
   69       public JspException(String msg) {
   70   	super(msg);
   71       }
   72   
   73   
   74       /**
   75        * Constructs a new JSP exception when the JSP 
   76        * needs to throw an exception and include a message 
   77        * about the "root cause" exception that interfered with its 
   78        * normal operation, including a description message.
   79        *
   80        *
   81        * @param message 		a <code>String</code> containing 
   82        *				the text of the exception message
   83        *
   84        * @param rootCause		the <code>Throwable</code> exception 
   85        *				that interfered with the servlet's
   86        *				normal operation, making this servlet
   87        *				exception necessary
   88        *
   89        */
   90       
   91       public JspException(String message, Throwable rootCause) {
   92   	super(message);
   93   	this.rootCause = rootCause;
   94       }
   95   
   96   
   97       /**
   98        * Constructs a new JSP exception when the JSP 
   99        * needs to throw an exception and include a message
  100        * about the "root cause" exception that interfered with its
  101        * normal operation.  The exception's message is based on the localized
  102        * message of the underlying exception.
  103        *
  104        * <p>This method calls the <code>getLocalizedMessage</code> method
  105        * on the <code>Throwable</code> exception to get a localized exception
  106        * message. When subclassing <code>JspException</code>, 
  107        * this method can be overridden to create an exception message 
  108        * designed for a specific locale.
  109        *
  110        * @param rootCause 	the <code>Throwable</code> exception
  111        * 				that interfered with the JSP's
  112        *				normal operation, making the JSP exception
  113        *				necessary
  114        *
  115        */
  116   
  117       public JspException(Throwable rootCause) {
  118   	super(rootCause.getLocalizedMessage());
  119   	this.rootCause = rootCause;
  120       }
  121   
  122       
  123       /**
  124        * Returns the exception that caused this JSP exception.
  125        *
  126        *
  127        * @return			the <code>Throwable</code> 
  128        *				that caused this JSP exception
  129        *
  130        */
  131       
  132       public Throwable getRootCause() {
  133   	return rootCause;
  134       }
  135   }

Save This Page
Home » glassfish-v2ur2-b04-src » javax » servlet » jsp » [javadoc | source]