What is the use of <c:redirect > tag in JSP?

JSPJava 8Object Oriented ProgrammingProgramming

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


The <c:redirect> tag has the following attributes −

urlURL to redirect the user's browser toYesNone
context/ followed by the name of a local web applicationNoCurrent application


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" %>
      <title><c:redirect> Tag Example</title>
      <c:redirect url = "http://www.photofuntoos.com"/>

The above code will redirect the request to http://www.photofuntoos.com - Try it yourself.

Published on 22-Mar-2019 10:17:30