001    /*
002    * Licensed to the Apache Software Foundation (ASF) under one or more
003    * contributor license agreements.  See the NOTICE file distributed with
004    * this work for additional information regarding copyright ownership.
005    * The ASF licenses this file to You under the Apache License, Version 2.0
006    * (the "License"); you may not use this file except in compliance with
007    * the License.  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    package javax.servlet.jsp;
018    
019    /**
020     * Contains information about an error, for error pages.
021     * The information contained in this instance is meaningless if not used
022     * in the context of an error page.  To indicate a JSP is an error page,
023     * the page author must set the isErrorPage attribute of the page directive
024     * to "true".
025     *
026     * @see PageContext#getErrorData
027     * @since 2.0
028     */
029    
030    public final class ErrorData {
031    
032        private Throwable throwable;
033        private int statusCode;
034        private String uri;
035        private String servletName;
036    
037        /**
038         * Creates a new ErrorData object.
039         *
040         * @param throwable The Throwable that is the cause of the error
041         * @param statusCode The status code of the error
042         * @param uri The request URI
043         * @param servletName The name of the servlet invoked
044         */
045        public ErrorData( Throwable throwable, int statusCode, String uri, 
046            String servletName )
047        {
048            this.throwable = throwable;
049            this.statusCode = statusCode;
050            this.uri = uri;
051            this.servletName = servletName;
052        }
053    
054        /**
055         * Returns the Throwable that caused the error.
056         *
057         * @return The Throwable that caused the error
058         */
059        public Throwable getThrowable() {
060            return this.throwable;
061        }
062    
063        /**
064         * Returns the status code of the error.
065         *
066         * @return The status code of the error
067         */
068        public int getStatusCode() {
069            return this.statusCode;
070        }
071    
072        /**
073         * Returns the request URI.
074         *
075         * @return The request URI
076         */
077        public String getRequestURI() {
078            return this.uri;
079        }
080    
081        /**
082         * Returns the name of the servlet invoked.
083         *
084         * @return The name of the servlet invoked
085         */
086        public String getServletName() {
087            return this.servletName;
088        }
089    }