Hi,
Some info about the response.sendRedirect() and jsp:forward.
response.sendRedirect() will generate another HTTP request from the client's
browser. This means that the servlet is actually handing over the control
back to the browser and ask it to generate a fresh request.
<jsp:forward> actually internally hands over the control to another
forwarded page. this way, new request is not generated.
In other words, response.redirect is executed at the browser but the
<jsp:forward> is executed at the web server. sendRedirect is useful when u
want to transfre the control to another web site all together, for example.
but if u want to transfer the control within your web site or web
application, use <jsp:forward> coz it is much faster as it is executed on
the server itself. If u wanna give the same effect in servlet, u can user
javax.servlet.getServletContext().getRequestDispatcher("jsp or html file
name").forward(requestobject,responseobject).
Another interesting point to remember is the URL in browser's location bar
will change with response.sendRedirect(), but not with a jsp forward. This
can confuse QA engineers; they enter bugs on a
particular JSP, but the one they are looking at isn't the one in the
location bar.
Keep it in mind when considering what happens if the user hits "back" or
"refresh", as well...
with a forward, the original request (before the forward) will happen again
in response to a reload.
Regards,
Sumit Mishra
mailto:[EMAIL PROTECTED]
http://www.cash-tech.com/
-----Original Message-----
From: A mailing list about Java Server Pages specification and
reference [mailto:[EMAIL PROTECTED]] On Behalf Of Shawn Zhu
Sent: Tuesday, March 20, 2001 10:45 AM
To: [EMAIL PROTECTED]
Subject: difference between sendRedirect and forward
What's the difference between sendRedirect and requestDispatcher.forward (or
<jsp:forward>)?
Is it getHeader("referer") will return different values?
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets