esuslogo
 [To advertise Java(tm) Events here, contact joris@esus.com!]
banner

Java™
by example!






New @ Esus.com


  gb  In-house search engine for better results!

  gb  Get updates with the esus.com
newsletter!









  Home 
 Browse Categories 
 Ask a Java Question 
 Help 
  For Java Tips & Tricks, subscribe to the esus.com newsletter!
Search Java Q&A, Links, API's:   adv 

What is the difference between <jsp:forward> and response.sendRedirect() ?

  • With response.sendRedirect(), the browser is asked to go get another page. All HTTP parameters of the original request are lost. The browser's location bar changes.
  • <jsp:forward> is more efficient. It forwards the request to the specified JSP page on the server side, without asking the browser to generate a new request. You can only forward to resources served by your application server! It also keeps the state.
    The browser's location bar doesn't change.

    To test it out, check out

    response.sendRedirect()
    http://www.javaspace.com/docs/DoRedirect.jsp?orderID=100

    <jsp:forward>
    http://www.javaspace.com/docs/DoForward.jsp?orderID=100

    DoRedirect.jsp:

    This code sample is only viewable to esus.com members
    Login or become a member!


    DoForward.jsp:

    This code sample is only viewable to esus.com members
    Login or become a member!


    ResultingPage.jsp:

    This code sample is only viewable to esus.com members
    Login or become a member!




    Further Information
    Author of answer: Joris Van den Bogaert

    Comments to this answer are only viewable by members. Login or become a member!





Terms of Service | Privacy Policy | Contact

Copyright © 2000-2003 Esus.com - All Rights Reserved 
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. Esus.com is independent of Sun Microsystems, Inc. All other trademarks are the sole property of their respective owners.