The difference is between redirect the customer to a page (sendRedirect) and forward a request to be met by another resource (forward).
In the first case (sendRedirect), the client will receive an http response at which header there will be information that he must order another page, and the browser will make this request. That is, the redirection takes place on the client side.
In the second case (forward), on the server side the user request will be forwarded to be met by another resource (other Servlet). This other Servlet eventually return another page to the user.
The difference is quite large especially when it comes to user experience.
Unfortunately there are many systems that use request forwarding when they should use redirect.
Examples of misuse of forward
The user clicks to save an edit (makes a Submit of the page). Then the server saves the data in the database and forwards (forward) the user to the page that displays for reading the newly edited record.
In the browser, the user made a Ubmit and as a response received the content from another page. The browser renders the content received but does not record that it is on another page and does not update for example the URL.
One of the problems with this is that the user will not be able to save the log view page for reading to his favorites. For the browser it is as if the user is still on the editing page. This also limits the use of the "back" and "forward" buttons of the browser, which will not offer the behavior that the user is used to.
Web experience
The experience proposed by the Web and that is usually expected by users, is that any Web system is composed of navigation between pages. Each feature is a different page, with its own URL, and you can go back to a previous resource and proceed again to the resource where it was before, you can save resources in the favorites to come back to them after easily, you can share these features by sharing Urls, etc..
Even the web systems that offer the experience single page application, if well designed, provide the user with this experience of browsing between pages. For example: gmail, google maps, facebook...
In these systems, the page is rarely or perhaps never fully reloaded, but only part of the content is redesigned. This improves the user experience but there is a huge concern so that he doesn’t miss out on that other basic experience of having the URL updated and then being able to access specific features via the back button or a URL saved in the favorites or shared with him by another user.
Use forwarding (forward) instead of using redirect (sendRedirect) kills this experience and does not motivate the developer to improve in web development because he gets used to taking resources on the server between a page and another, when it should mainly use the information contained in user requests and save very little or no status on the server.
it would be of great help to know some more problems of using forwarding instead of redirecting.
– Pena Pintada
@Very interesting, thank you!! I’ll stay tuned for the Bookmark bid!
– Pena Pintada
@Caffé, thank you very much for the enlightening answer, was just with this problem of not updating the URL when returning from Servlet and I managed to solve following his tip. Simply swap: request.getRequestDispatcher(). forward(".jsp file"); request.setAttribute("objObject", object); Por: Resp.sendRedirect(request.getContextPath() + "/resource/" + Object.getId());
– Silvair L. Soares