<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<table border="1">
<tr>
<TH>Scoped Variable</th>
<TH>Current Value</th>
</tr>
<tr>
<td>
<b>Page Scope</b>
(scopeVarPage)</td>
<td> 
<c:out value="${scopeVarPage}" />
</td>
</tr>
<tr>
<td>
<b>Request Scope</b>
(scopeVarRequest)</td>
<td> 
<c:out value="${scopeVarRequest}" />
</td>
</tr>
<tr>
<td>
<b>Session Scope</b>
(scopeVarSession)</td>
<td> 
<c:out value="${scopeVarSession}" />
</td>
</tr>
<tr>
<td>
<b>Application Scope</b>
(applicationVarPage)</td>
<td> 
<c:out value="${scopeVarApplication}" />
</td>
</tr>
</table>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
<head>
<title>Scope Example</title>
</head>
<body>
<h3>Linked File: linked.jsp</h3>
<table border="1">
<tr>
<TH>Scoped Variable</th>
<TH>Current Value</th>
</tr>
<tr>
<td>
<b>Page Scope</b>
(scopeVarPage)</td>
<td> 
<c:out value="${scopeVarPage}" />
</td>
</tr>
<tr>
<td>
<b>Request Scope</b>
(scopeVarRequest)</td>
<td> 
<c:out value="${scopeVarRequest}" />
</td>
</tr>
<tr>
<td>
<b>Session Scope</b>
(scopeVarSession)</td>
<td> 
<c:out value="${scopeVarSession}" />
</td>
</tr>
<tr>
<td>
<b>Application Scope</b>
(applicationVarPage)</td>
<td> 
<c:out value="${scopeVarApplication}" />
</td>
</tr>
</table>
</body>
</html>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
<head>
<title>Catch an Exception</title>
</head>
<body>
<c:catch var="e">
<c:set var="x" value="10" scope="page" />
<c:set var="y" value="five" scope="page" />
x divided by y is
<c:out value="${x/y}" />
<br />
</c:catch>
<br />
<c:if test="${e!=null}">The caught exception is:
<c:out value="${e}" />
<br />
</c:if>
<c:if test="${e==null}">No exception was thrown
<br />
</c:if>
</body>
</html>
Download: JSTLSetValueForVariable.zip( 1,247 k)