index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Index Page</title>
</head>
<body>
<form action="JSTL.jsp" method="post">
First Name:<input type="text" name="fname"/><br> <br>
Last Name:<input type="text" name="lname"/><br><br>
<input type="submit" value="Check JSTL Demo"/>
</form>
</body>
</html>
JSTL.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome Page</title>
</head>
<body>
First Name:<b><c:out value="${param.fname}"></c:out></b><br>
Last Name:<b><c:out value="${param.lname}"></c:out></b><br><br>
Use of if Statement
<br>
<c:set var="mycount" value="25"/>
<c:if test="${mycount==25}">
<b><c:out value="Your count is 25"/></b>
</c:if>
<br><br>
Use of forEach Statement
<br>
<c:forEach var="count" begin="101" end="105">
<b><c:out value="${count}"/></b>
</c:forEach>
<br><br>
Exception catching Example
<p>
<c:catch var="myException">
<%int number=10/0;%>
</c:catch>
<b>The Exception is:${myException}</b>
</p>
</body>
</html>
0 Comments