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 // 021 // This source code implements specifications defined by the Java 022 // Community Process. In order to remain compliant with the specification 023 // DO NOT add / change / or delete method signatures! 024 // 025 026 package javax.servlet.jsp; 027 028 /** 029 * Contains information about an error, for error pages. 030 * The information contained in this instance is meaningless if not used 031 * in the context of an error page. To indicate a JSP is an error page, 032 * the page author must set the isErrorPage attribute of the page directive 033 * to "true". 034 * 035 * @see PageContext#getErrorData 036 * @since 2.0 037 */ 038 039 public final class ErrorData { 040 041 private Throwable throwable; 042 private int statusCode; 043 private String uri; 044 private String servletName; 045 046 /** 047 * Creates a new ErrorData object. 048 * 049 * @param throwable The Throwable that is the cause of the error 050 * @param statusCode The status code of the error 051 * @param uri The request URI 052 * @param servletName The name of the servlet invoked 053 */ 054 public ErrorData( Throwable throwable, int statusCode, String uri, 055 String servletName ) 056 { 057 this.throwable = throwable; 058 this.statusCode = statusCode; 059 this.uri = uri; 060 this.servletName = servletName; 061 } 062 063 /** 064 * Returns the Throwable that caused the error. 065 * 066 * @return The Throwable that caused the error 067 */ 068 public Throwable getThrowable() { 069 return this.throwable; 070 } 071 072 /** 073 * Returns the status code of the error. 074 * 075 * @return The status code of the error 076 */ 077 public int getStatusCode() { 078 return this.statusCode; 079 } 080 081 /** 082 * Returns the request URI. 083 * 084 * @return The request URI 085 */ 086 public String getRequestURI() { 087 return this.uri; 088 } 089 090 /** 091 * Returns the name of the servlet invoked. 092 * 093 * @return The name of the servlet invoked 094 */ 095 public String getServletName() { 096 return this.servletName; 097 } 098 }