|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Defines an object that receives requests from the client
and sends them to any resource (such as a servlet,
HTML file, or JSP file) on the server. The servlet
engine creates the RequestDispatcher
object,
which is used as a wrapper around a server resource located
at a particular path.
This interface is intended to wrap servlets,
but a servlet engine can create RequestDispatcher
objects to wrap any type of resource.
ServletContext.getRequestDispatcher(java.lang.String)
Method Summary | |
void |
forward(ServletRequest request,
ServletResponse response)
Forwards a ServletRequest object from
this servlet to a resource (servlet, JSP file, or
HTML file) on the server. |
void |
include(ServletRequest request,
ServletResponse response)
Includes the content a resource (servlet, JSP page, HTML file) on the Web server generates in the response this servlet sends to another servlet. |
Method Detail |
public void forward(ServletRequest request, ServletResponse response) throws ServletException, java.io.IOException
ServletRequest
object from
this servlet to a resource (servlet, JSP file, or
HTML file) on the server. You can use this method
when one servlet does preliminary processing of
a request and lets another resource generate
the response.
The ServletRequest
object has its
path and other parameters adjusted to be relative
to the path of the target resource.
You cannot use forward
if the target
resource has already returned a ServletOutputStream
or PrintWriter
object to the servlet.
In that situation, forward
throws
an IllegalStateException
.
request
- a ServletRequest
object
that represents the request the client
makes of the servletresponse
- a ServletResponse
object
that represents the response the servlet
returns to the clientServletOutputStream
or PrintWriter
object before
this method was calledpublic void include(ServletRequest request, ServletResponse response) throws ServletException, java.io.IOException
The ServletResponse
object passed to this
servlet has the caller's request path. The response
object only has access to this servlet's
ServletOutputStream
and PrintWriter
objects.
A servlet that calls include
cannot
set response headers. If the servlet that calls
include
also calls methods that set
headers, include
is not guaranteed
to work.
request
- a ServletRequest
object
that contains the client's requestresponse
- a ServletResponse
object
that contains the servlet's responseServletOutputStream
or
print writer object from the
ServletResponse
object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |