I think it is easier to compare the forward and redirect actions. For this reason, we will also introduce the logic: Forward and logic: Redirect tags here.
Let's take a look at the differences between the two actions:
Forward is executed within the servlet. the browser will not perceive this action at all, and the original URL will not change. If the browser reloads, it will simply repeat the original request.
Redirect is divided into two steps: the first step is that the Web application tells the browser the second URL, and then the browser sends a request to the second URL.
Redirect is slower than forward because the browser requires a second request. Note that the bean in the first request scope is invisible to the second request.
After understanding the differences described above, you will know when to choose the logic: Forward label and when to choose the logic: Redirect label. Logic: the forward label completes pagecontext. Forward () or httpservletresponse. sendredirect (). The Controller determines how to choose. Logic: the Redirect label completes httpservletresponse. sendredirect ().
When using the logic: Redirect tag, we can construct baseurl and query parameters like HTML: link. If you are interested, refer to HTML: link tag.