In this post, you will learn how to use the <c:redirect> tag in the JSTL core tags libarary with example.

You know, the <c:redirect> redirects the browser to a new alternate URL. The <c:param> tag can be used to supply additional request parameters and values if required.

 

JSTL <c:redirect> Syntax:

<c:redirect url="<string>" context="<string>"/>

 

Attributes:

Name

Required

Type

Description

url

False

java.lang.String

The URL of the resource to redirect the browser to.

context

False

java.lang.String

Web application context when redirecting to a relative URL of an external resource.

 

JSTL <c:redirect> Example:

The below example redirects the browser to Codejava.net website.

<c:redirect url="http://www.codejava.net"/>

 

Recommended Usage of JSTL <c:redirect> tag:

Useful to redirect to a new URL altogether. Note that browser will create a new request and performs the redirection.

 

Other JSTL Core Tags:

if |  catch  |  choose   |  forEach  |  forTokens   |  import   |  out   |  param  |  remove   |  set  |  url


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Add comment