I am using servlet there is two method redirect and forward both are send request to the same page but what is the difference between them.any idea
The Forward method forwards a request from one servlet to another resource in a web application and this resource can be another servlet, JSP page, or HTML file. The Redirect method, on the other hand, redirects the request to a different application. You cannot do this with a forward method.
This rule will redirect the emails as if they came directly from the original sender's email address. If you use forward, your email will be forwarded to another email address, but you will not be able to reply to the original sender.
(a) forward executes on the client while sendRedirect() executes on the server. (b) forward executes on the server while sendRedirect() executes on the client. (c) The two methods perform identically.
The RequestDispatcher interface allows you to do a server side forward/include whereas sendRedirect() does a client side redirect. SendRedirect() will search the content between the servers. it is slow because it has to intimate the browser by sending the URL of the content.
redirect - it uses a browser redirect. It sends an http response with code 3xx (see wikipedia), and then the browser makes another request to the new page
forward - forward is internal for the servlet container. The browser never understands that the page has changed. Hence the URL doesn't change (like with redirect), and you have the same request in the new page as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With