JSTL Core tag – redirect() : Function



The <c:redirect> tag redirects the browser to an alternate URL by providing automatically URL rewriting, it supports context-relative URLs, and it supports the <c:param> tag.

Attribute:

The <c:redirect> tag has following attributes:

Attribute Description Required Default
url URL to redirect the user’s browser to Yes None
context / followed by the name of a local web application No Current application

JSTL Example :

If you need to pass parameters to a <c:import> tag, use the <c:url> tag to create the URL first as shown below:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>JSTL Tag Example</title>
</head>
<body>

<c:redirect url="http://www.c4learn.com"/>

</body>
</html>

Above example would redirect request to http://www.c4learn.com