|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Defines a request dispatcher object that receives request from the client and sends them to any resource (such as a servlet, CGI script, HTML file, or JSP file) available on the server. The request dispatcher object is created by the servlet engine and serves as a wrapper around a server resource defined by a particular URL path.
The RequestDispatcher interface is defined primary to wrap servlets, but a servlet engine can create request dispatcher objects to wrap any type of resource.
Request dispatcher objects are created by the servlet engine, not by the servlet developer.
ServletContext.getRequestDispatcher(java.lang.String)
Method Summary | |
void |
forward(ServletRequest request,
ServletResponse response)
Used for forwarding a request from this servlet to another resource on the server. |
void |
include(ServletRequest request,
ServletResponse response)
Used for including the content generated by another server resource in the body of a response. |
Method Detail |
public void forward(ServletRequest request, ServletResponse response) throws ServletException, java.io.IOException
The request object passed to the target object will have its request URL path and other path parameters adjusted to reflect the target URL path of the target ojbect.
You cannot use this method if a ServletOutputStream object or PrintWriter object has been obtained from the response. In that case, the method throws an IllegalStateException
request
- the client's request on the servletresponse
- the client's response from the servletpublic void include(ServletRequest request, ServletResponse response) throws ServletException, java.io.IOException
The request object passed to the target object will reflect the request URL path and path info of the calling request. The response object only has access to the calling servlet's ServletOutputStream object or PrintWriter object.
An included servlet cannot set headers. If the included servlet calls a method that may need to set headers (such as sessions might need to), the method is not guaranteed to work. As a servlet developer, you must ensure that any methods that might need direct access to headers are properly resolved. To ensure that a session works correctly, start the session outside of the included servlet, even if you use session tracking.
request
- the client's request on the servletresponse
- the client's response from the servlet
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |