How can I do the following
response.sendRedirect("index.jsp");
after a certain time interval from another jsp without using javascript or php?
The idea is to show an error in a “error_page.jsp” and then after some time automatically redirect the user to the index page. Thanks in advance.
Refresh HTTP header is supposed to control timed redirects.
You can set it in HTML, by adding to your
error_page.jspthis meta tag:(5 stands for 5 seconds before
next_page.jspgets loaded)You would most probably pass the name of the next page as a parameter to the JSP, or a request attribute, so that instead of
next_page.jspit would be${param.nextPage}or just${nextPage}respectively.And of course you can set the same header from servlet:
response.setHeader("Refresh", "5;url=next_page.jsp");.You could even put this code inside JSP
<% response.setHeader("Refresh", "5;url=next_page.jsp"); %>.