January 10, 2010

Java Servlet API - Difference between forward, include, redirect

« Useful Java tools | Main | Spring Framework Example »

For the correct request handling of the Java Servlet API Java developers have to undestand the differences of forward-, include- and redirect-methods.

  • ServletResponse.sendRedirect(String location): Sends a temporary redirect to the HTTP client. Only absolute URLs are allowed.
  • HttpRequest.getRequestDispatcher("example.jsp").forward(request, response): Delegates one HttpRequest to another dynamic or static resource.
  • HttpRequest.getRequestDispatcher("example.html").include(request, response): Includes/enriches current response with another dynamic or static resource.
Regards
Rafael Sobek

Technorati Tags:

Posted by rafael.sobek at 6:08 PM in Java

 

[Trackback URL for this entry]

Comment: dhrupal at Di, 29 Nov 5:13 AM

thanx

Your comment:

(not displayed)
 
 
 

Live Comment Preview: