Wednesday, April 15, 2009

The JSTL Fine Print

There are subtle differences between JSTL 1.0 and 1.1. For example at the EL level.

For JSTL 1.0:
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<html>
<head>
<title>test</title>
</head>
<body>
<h1>JSTL here</h1>
<c:set var="bla" value="${param.aaa}">
Parameter "aaa": <c:out value="${bla}">
<br/><br/>
Empty: <c:out value="${empty bla}">
<br/><br/>
<c:set var="browser" value="${header['User-Agent']}">
Browser user agent: <c:out value="${browser}">
</body>
</html>

For JSTL 1.1:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<title>Test</title>
</head>
<body>
<c:set var="bla" value="${param.aaa}"/>
${bla}: ${!empty bla}
<br/><br/>
<c:set var="browser" value="${header['User-Agent']}"/>
${browser}
</body>
</html>

No comments:

Post a Comment