I have to design several pages in jsp. After clicking on the submit button on the first page, the page should be automatically redirected to the second page.
Can you help with a quick example or a link to a tutorial that demonstrates how to implement this?
The page redirect is used to move the redirect response to another resource of the web page. Basically we can call the redirect pages using sendRedirect() method in the jsp on client-side request can be used within the server or outside of the server.
Just use two forms. In the first form action attribute will have name of the second jdp page and your 1st button. In the second form there will be 2nd button with action attribute thats giving the name of your 3rd jsp page.
sendRedirect() accepts the respective URL to which the request is to be redirected. Can redirect the request to another resource like Servlet, HTML page, or JSP page that are inside or outside the server. It works on the HTTP response object and always sends a new request for the object.
<% String redirectURL = "http://whatever.com/myJSPFile.jsp"; response.sendRedirect(redirectURL); %>
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