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]

Your comment:

(not displayed)
 
 
 

Live Comment Preview:

 
« January »
SunMonTueWedThuFriSat
     12
3456789
10111213141516
17181920212223
24252627282930
31