Sunday, 11 September 2016

JSTL example in jsp . JSTL out tags, JSTL set tags,JSTL choose tags, JSTL When tags, JSTL catch tags, JSTL foreach tags, JSTL if tags

<%--
Document   : SampleJSTL
Created on : Sep 9, 2016, 9:09:25 AM
Author     : Alok Panday
--%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="pg" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>

<pg:set var="name" value="javatreepoint"></pg:set>
<pg:choose>
<pg:when test="${name=='jaatreepoint'}">
<pg:out value="${name}"></pg:out>
</pg:when>
<pg:otherwise>
<pg:out value="not maching"></pg:out>
</pg:otherwise>
</pg:choose>
<pg:catch var="ex">
<pg:out value="${45/0}"></pg:out>
</pg:catch>
<pg:if test="${ex!=null}">
${ex}

</pg:if>
<pg:forEach begin="0" end="10" step="2" var="i" >
${i}
</pg:forEach>
<pg:import url="index.html" ></pg:import>

</body>
JSP Page ${ex} ${i}
</html>

1 comment: