1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package javax.servlet.jsp;
18
19 /**
20 * Contains information about an error, for error pages.
21 * The information contained in this instance is meaningless if not used
22 * in the context of an error page. To indicate a JSP is an error page,
23 * the page author must set the isErrorPage attribute of the page directive
24 * to "true".
25 *
26 * @see PageContext#getErrorData
27 * @since 2.0
28 */
29
30 public final class ErrorData {
31
32 private Throwable throwable;
33 private int statusCode;
34 private String uri;
35 private String servletName;
36
37 /**
38 * Creates a new ErrorData object.
39 *
40 * @param throwable The Throwable that is the cause of the error
41 * @param statusCode The status code of the error
42 * @param uri The request URI
43 * @param servletName The name of the servlet invoked
44 */
45 public ErrorData( Throwable throwable, int statusCode, String uri,
46 String servletName )
47 {
48 this.throwable = throwable;
49 this.statusCode = statusCode;
50 this.uri = uri;
51 this.servletName = servletName;
52 }
53
54 /**
55 * Returns the Throwable that caused the error.
56 *
57 * @return The Throwable that caused the error
58 */
59 public Throwable getThrowable() {
60 return this.throwable;
61 }
62
63 /**
64 * Returns the status code of the error.
65 *
66 * @return The status code of the error
67 */
68 public int getStatusCode() {
69 return this.statusCode;
70 }
71
72 /**
73 * Returns the request URI.
74 *
75 * @return The request URI
76 */
77 public String getRequestURI() {
78 return this.uri;
79 }
80
81 /**
82 * Returns the name of the servlet invoked.
83 *
84 * @return The name of the servlet invoked
85 */
86 public String getServletName() {
87 return this.servletName;
88 }
89 }