001    /**
002     *
003     * Copyright 2003-2004 The Apache Software Foundation
004     *
005     *  Licensed under the Apache License, Version 2.0 (the "License");
006     *  you may not use this file except in compliance with the License.
007     *  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    
018    //
019    // This source code implements specifications defined by the Java
020    // Community Process. In order to remain compliant with the specification
021    // DO NOT add / change / or delete method signatures!
022    //
023    
024    package javax.servlet.jsp;
025    
026    /**
027     * Contains information about an error, for error pages.
028     * The information contained in this instance is meaningless if not used
029     * in the context of an error page.  To indicate a JSP is an error page,
030     * the page author must set the isErrorPage attribute of the page directive
031     * to "true".
032     *
033     * @see PageContext#getErrorData
034     * @since 2.0
035     */
036    
037    public final class ErrorData {
038    
039        private Throwable throwable;
040        private int statusCode;
041        private String uri;
042        private String servletName;
043    
044        /**
045         * Creates a new ErrorData object.
046         *
047         * @param throwable The Throwable that is the cause of the error
048         * @param statusCode The status code of the error
049         * @param uri The request URI
050         * @param servletName The name of the servlet invoked
051         */
052        public ErrorData( Throwable throwable, int statusCode, String uri, 
053            String servletName )
054        {
055            this.throwable = throwable;
056            this.statusCode = statusCode;
057            this.uri = uri;
058            this.servletName = servletName;
059        }
060    
061        /**
062         * Returns the Throwable that caused the error.
063         *
064         * @return The Throwable that caused the error
065         */
066        public Throwable getThrowable() {
067            return this.throwable;
068        }
069    
070        /**
071         * Returns the status code of the error.
072         *
073         * @return The status code of the error
074         */
075        public int getStatusCode() {
076            return this.statusCode;
077        }
078    
079        /**
080         * Returns the request URI.
081         *
082         * @return The request URI
083         */
084        public String getRequestURI() {
085            return this.uri;
086        }
087    
088        /**
089         * Returns the name of the servlet invoked.
090         *
091         * @return The name of the servlet invoked
092         */
093        public String getServletName() {
094            return this.servletName;
095        }
096    }