Is it possible to redirect a user automatically to a second jsp page as soon as the home page loads?
Asked
Active
Viewed 5.4k times
2 Answers
28
With core JSTL libraries loaded <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
you can use:
<c:redirect url="/home.html"/>

JohnMark13
- 3,709
- 1
- 15
- 26
-
-
2Sure, all over the place. Did you look? Here is an example http://www.devmanuals.com/tutorials/java/jsp/jstl/CoreTagRedirect.html and another http://www.tutorialspoint.com/jsp/jstl_core_redirect_tag.htm and some notes from IBM http://www.ibm.com/developerworks/library/j-jstl0318/ – JohnMark13 Jun 16 '14 at 11:54
3
There is an example of such a thing: JSP - Page Redirecting
Simplest is using sendRedirect
:
public void response.sendRedirect(String location)
throws IOException

Zoe
- 27,060
- 21
- 118
- 148

Peter Trypsteen
- 179
- 3
-
1Whilst this is the accepted answer, you should try hard to minimise the amount of scriptlets in your JSP as they inevitably add untestable complexity. If you need a tutorial which achieves the same thing using standard tag libraries see http://www.tutorialspoint.com/jsp/jstl_core_redirect_tag.htm – JohnMark13 Sep 02 '13 at 18:44