|
|
if tag in JSP Core Tag Library
|
Tutorials

Jsp

|
Topic |
How is if tag of JSP Core Tag Library used?
|
|
Explanation |
|
The if tags is used to execute a set of code based on the value of its attribute "test".
Syntax:
<c:if test="booleanexpression"
var="var" [scope="page|request|session|application"]/>
In the above syntax the "var" attribute stores the instance of the value of the "test" attribute. The "scope"
attribute refers the scope of variable "var".
Example:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<form>
<h5>if tag in Core tag library</h5>
Username:<input type="text" name="user" size="25">
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
<br><br>
<c:if test="${param.user==''}">
Enter a valid Username
</c:if>
In the above example using the "if" tag we get the value entered in the username field using "param.user", if
its empty it displays the message "Enter a valid Username".
|
|
A Note |
|
JSP(Java Server Pages) is one of the most used Server Side Programming Language in the world. Simple introduction, basic program codes with examples. Begin coding your own JSP scripts with this online tutorial. Hope you enjoy this tutorial. Do send your feedback or suggestions on this JavaServer Pages tutorial. This is a copyright content.
|
|
|
|