JSTL Core Tag c:redirect Example
- Details
- Written by Nam Ha Minh
- Last Updated on 31 August 2019   |   Print Email
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:
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.
Comments