JSTL Redirect Tag Example

JSTL Redirect Tag Example explains about how to use jstl redirect tag in order to redirect the request to another url

Consider an example, where you need to redirected a page, according to some condition, in that case you can use JSTL c:redirect Tag

Inside c:redirect Tag, you can specify following attributes.

url -> This attribute specify the resource need to be redirected.

context -> This attribute specify the context name when redirecting whether it is relative or absolute

You can see the below example demonstrating the usage JSTL c:redirect Tag Example inside JSP

Required Libraries

You need to download

  1. Tomcat 9
  2. JSTL 1.2

Following jar must be in classpath

  1. jstl-1.2.jar

JSTL c:redirect Tag Example

<!--JSTL Redirect Tag Example-->

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<title>JSTL Redirect Tag Example</title>
//invoking c:redirect tag
<c:redirect url="http://www.javatips.net"></c:redirect>
JSTL Redirect Tag Example

Your email address will not be published. Required fields are marked *