Interface RequestDispatcher
A servlet can get an object that implements this interface from
the ServletContext by calling the
getRequestDispatcher() method.
If the servlet engine can it should provide a (wrapper) object which
implements this interface when a servlet calls
getRequestDispatcher().
- Since:
- Servlet API 2.1
- Version:
- Servlet API 2.2
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidforward(ServletRequest request, ServletResponse response) Forwards aServletRequestto the resource represented by theRequestDispatcher.voidinclude(ServletRequest request, ServletResponse response) Includes into theServletResponseany output written by the resource represented by theRequestDispatcher.
-
Method Details
-
forward
Forwards aServletRequestto the resource represented by theRequestDispatcher.A servlet can call this method if it has not yet requested an
OutputStreamor aWriterfrom theresponse.Note that the
RequestDispatchercan change therequestobject before handing it to the target resource depending on the string that was given togetRequestDispatcher().- Parameters:
request- the original requestresponse- the response to which output should be written- Throws:
ServletException- can be thrown by the target resourceIOException- if an I/O-error occursIllegalStateException- ifgetOutputStreamorgetWriterhas already been called on theresponse- Since:
- Servlet API 2.1
-
include
Includes into theServletResponseany output written by the resource represented by theRequestDispatcher.Note that the target resource can only use the
OutputStreamorWriterthat the original caller uses. It can not set any headers. Also note that any sessions should be started before calling include.The RequestDispatcher will not alter the original
requestbefore handing it to the target resource.- Parameters:
request- the original requestresponse- the original response- Throws:
ServletException- can be thrown by the target resourceIOException- if an I/O-error occurs- Since:
- Servlet API 2.1
-