Sunday, December 30, 2012

Servlet dispatch

http://blog.csdn.net/bluishglc/article/details/7953614
Redirect: the redirection on the client side.

Servlet dispatch
Services are often composed of many Servlets (and JSP pages) working together.
Forwarding a request to another Servlet using RequestDispatcher:

RequestDispatcher dispatcher =   getServletContext().getRequestDispatcher("/my_other_app/servlet/SomeServlet");
dispatcher.forward(request, response);

request.setAttribute(String,String) can be used to supply extra data to the new handler
  • forward - complete transfer of control to another Servlet
  • include - insert result from running another Servlet (another kind of "wrapping")

No comments:

Post a Comment