Posts

Showing posts with the label forward

How to redirect or forward request in Hybris?

What is basic difference between request Redirect Vs Forward? Redirect:  Server sends a header (in response) back to the browser/client, which contain redirect URL, then browser initiates a new request to redirect URL. Browser creates a new request to the redirected URL. The browser displays the redirected URL. The client browser is involved. Redirect is slower. When can we use Redirect? @RequestMapping(value = "/originalurl", method = {RequestMethod.POST}) public String method(final Model model) { // ... return "redirect:/redirectToGeturl"; } Usually, when data is posted to the server, we should redirect to get method(URL). So browser displays redirected URL(/redirectToGeturl). Which also prevent data resubmission on browser refreshed(F5) as the request to will go to redirected URL(/redirectToGeturl). Forward:  Within the server, control can be forwarded to target resource(URL). Which is done by container internally so browser/clie