blob: 73687a117192722bda00b1453918b2be4843fa76 [file] [log] [blame]
Michael E. Rodriguezd8af66f2005-12-08 20:55:55 +00001/*
2 * Copyright 1999,2005 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18package javax.servlet;
19
20import java.io.IOException;
21
22
23/**
24 * Defines an object that receives requests from the client
25 * and sends them to any resource (such as a servlet,
26 * HTML file, or JSP file) on the server. The servlet
27 * container creates the <code>RequestDispatcher</code> object,
28 * which is used as a wrapper around a server resource located
29 * at a particular path or given by a particular name.
30 *
31 * <p>This interface is intended to wrap servlets,
32 * but a servlet container can create <code>RequestDispatcher</code>
33 * objects to wrap any type of resource.
34 *
35 * @author Various
36 * @version $Version$
37 *
38 * @see ServletContext#getRequestDispatcher(java.lang.String)
39 *
40 */
41
42public interface RequestDispatcher {
43
44
45
46
47
48/**
49 * Forwards a request from
50 * a servlet to another resource (servlet, JSP file, or
51 * HTML file) on the server. This method allows
52 * one servlet to do preliminary processing of
53 * a request and another resource to generate
54 * the response.
55 *
56 * <p>For a <code>RequestDispatcher</code> obtained via
57 * <code>getRequestDispatcher()</code>, the <code>ServletRequest</code>
58 * object has its path elements and parameters adjusted to match
59 * the path of the target resource.
60 *
61 * <p><code>forward</code> should be called before the response has been
62 * committed to the client (before response body output has been flushed).
63 * If the response already has been committed, this method throws
64 * an <code>IllegalStateException</code>.
65 * Uncommitted output in the response buffer is automatically cleared
66 * before the forward.
67 *
68 * <p>The request and response parameters must be the same
69 * objects as were passed to the calling servlet's service method.
70 *
71 *
72 * @param request a {@link ServletRequest} object
73 * that represents the request the client
74 * makes of the servlet
75 *
76 * @param response a {@link ServletResponse} object
77 * that represents the response the servlet
78 * returns to the client
79 *
80 * @exception ServletException if the target resource throws this exception
81 *
82 * @exception IOException if the target resource throws this exception
83 *
84 * @exception IllegalStateException if the response was already committed
85 *
86 */
87
88 public void forward(ServletRequest request, ServletResponse response)
89 throws ServletException, IOException;
90
91
92
93
94 /**
95 *
96 * Includes the content of a resource (servlet, JSP page,
97 * HTML file) in the response. In essence, this method enables
98 * programmatic server-side includes.
99 *
100 * <p>The {@link ServletResponse} object has its path elements
101 * and parameters remain unchanged from the caller's. The included
102 * servlet cannot change the response status code or set headers;
103 * any attempt to make a change is ignored.
104 *
105 * <p>The request and response parameters must be the same
106 * objects as were passed to the calling servlet's service method.
107 *
108 *
109 * @param request a {@link ServletRequest} object
110 * that contains the client's request
111 *
112 * @param response a {@link ServletResponse} object
113 * that contains the servlet's response
114 *
115 * @exception ServletException if the included resource throws this exception
116 *
117 * @exception IOException if the included resource throws this exception
118 *
119 *
120 */
121
122 public void include(ServletRequest request, ServletResponse response)
123 throws ServletException, IOException;
124}
125
126
127
128
129
130
131
132