001:
002: /*
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
004: *
005: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
006: *
007: * Portions Copyright Apache Software Foundation.
008: *
009: * The contents of this file are subject to the terms of either the GNU
010: * General Public License Version 2 only ("GPL") or the Common Development
011: * and Distribution License("CDDL") (collectively, the "License"). You
012: * may not use this file except in compliance with the License. You can obtain
013: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
014: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
015: * language governing permissions and limitations under the License.
016: *
017: * When distributing the software, include this License Header Notice in each
018: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
019: * Sun designates this particular file as subject to the "Classpath" exception
020: * as provided by Sun in the GPL Version 2 section of the License file that
021: * accompanied this code. If applicable, add the following below the License
022: * Header, with the fields enclosed by brackets [] replaced by your own
023: * identifying information: "Portions Copyrighted [year]
024: * [name of copyright owner]"
025: *
026: * Contributor(s):
027: *
028: * If you wish your version of this file to be governed by only the CDDL or
029: * only the GPL Version 2, indicate your decision by adding "[Contributor]
030: * elects to include this software in this distribution under the [CDDL or GPL
031: * Version 2] license." If you don't indicate a single choice of license, a
032: * recipient has the option to distribute your version of this file under
033: * either the CDDL, the GPL Version 2 or to extend the choice of license to
034: * its licensees as provided above. However, if you add GPL Version 2 code
035: * and therefore, elected the GPL Version 2 license, then the option applies
036: * only if the new code is made subject to such option by the copyright
037: * holder.
038: */
039:
040: package javax.servlet;
041:
042: import java.io.IOException;
043:
044: /**
045: * Defines an object that receives requests from the client
046: * and sends them to any resource (such as a servlet,
047: * HTML file, or JSP file) on the server. The servlet
048: * container creates the <code>RequestDispatcher</code> object,
049: * which is used as a wrapper around a server resource located
050: * at a particular path or given by a particular name.
051: *
052: * <p>This interface is intended to wrap servlets,
053: * but a servlet container can create <code>RequestDispatcher</code>
054: * objects to wrap any type of resource.
055: *
056: * @author Various
057: *
058: * @see ServletContext#getRequestDispatcher(java.lang.String)
059: * @see ServletContext#getNamedDispatcher(java.lang.String)
060: * @see ServletRequest#getRequestDispatcher(java.lang.String)
061: *
062: */
063:
064: public interface RequestDispatcher {
065:
066: /**
067: * Forwards a request from
068: * a servlet to another resource (servlet, JSP file, or
069: * HTML file) on the server. This method allows
070: * one servlet to do preliminary processing of
071: * a request and another resource to generate
072: * the response.
073: *
074: * <p>For a <code>RequestDispatcher</code> obtained via
075: * <code>getRequestDispatcher()</code>, the <code>ServletRequest</code>
076: * object has its path elements and parameters adjusted to match
077: * the path of the target resource.
078: *
079: * <p><code>forward</code> should be called before the response has been
080: * committed to the client (before response body output has been flushed).
081: * If the response already has been committed, this method throws
082: * an <code>IllegalStateException</code>.
083: * Uncommitted output in the response buffer is automatically cleared
084: * before the forward.
085: *
086: * <p>The request and response parameters must be either the same
087: * objects as were passed to the calling servlet's service method or be
088: * subclasses of the {@link ServletRequestWrapper} or {@link ServletResponseWrapper} classes
089: * that wrap them.
090: *
091: *
092: * @param request a {@link ServletRequest} object
093: * that represents the request the client
094: * makes of the servlet
095: *
096: * @param response a {@link ServletResponse} object
097: * that represents the response the servlet
098: * returns to the client
099: *
100: * @exception ServletException if the target resource throws this exception
101: *
102: * @exception IOException if the target resource throws this exception
103: *
104: * @exception IllegalStateException if the response was already committed
105: *
106: */
107:
108: public void forward(ServletRequest request, ServletResponse response)
109: throws ServletException, IOException;
110:
111: /**
112: *
113: * Includes the content of a resource (servlet, JSP page,
114: * HTML file) in the response. In essence, this method enables
115: * programmatic server-side includes.
116: *
117: * <p>The {@link ServletResponse} object has its path elements
118: * and parameters remain unchanged from the caller's. The included
119: * servlet cannot change the response status code or set headers;
120: * any attempt to make a change is ignored.
121: *
122: * <p>The request and response parameters must be either the same
123: * objects as were passed to the calling servlet's service method or be
124: * subclasses of the {@link ServletRequestWrapper} or {@link ServletResponseWrapper} classes
125: * that wrap them.
126: *
127: *
128: *
129: * @param request a {@link ServletRequest} object
130: * that contains the client's request
131: *
132: * @param response a {@link ServletResponse} object
133: * that contains the servlet's response
134: *
135: * @exception ServletException if the included resource throws this exception
136: *
137: * @exception IOException if the included resource throws this exception
138: *
139: *
140: */
141:
142: public void include(ServletRequest request, ServletResponse response)
143: throws ServletException, IOException;
144: }
|