<%@ page contentType="text/html;charset=MS932" %>
<html>
<head>
<title>EL Object Example</title>
</head>
<body>
<%! String str = "variable"; %>
<%
pageContext.setAttribute("str","page");
request.setAttribute("str","request");
session.setAttribute("str","session");
application.setAttribute("str","application");
%>
<table border="1">
<tr><th>EL式</th><th>値</th><th>説明</th></tr>
<tr>
<td>\${str}</td>
<td>${str}</td>
<td>page,request,session,applicationの順にオブジェクトを検索する</td>
</tr>
<tr>
<td>\${pageScope.str}</td>
<td>${pageScope.str}</td>
<td>pageスコープのオブジェクトの取得
</tr>
<tr>
<td>\${requestScope.str}</td>
<td>${requestScope.str}</td>
<td>requestスコープのオブジェクトの取得
</tr>
<tr>
<td>\${sessionScope.str}</td>
<td>${sessionScope.str}</td>
<td>sessionスコープのオブジェクトの取得
</tr>
<tr>
<td>\${applicationScope.str}</td>
<td>${applicationScope.str}</td>
<td>applicationスコープのオブジェクトの取得
</tr>
<tr>
<td>\${param.arg1}</td>
<td>${param.arg1}</td>
<td>requestパラメータの取得</td>
</tr>
<tr>
<td>\${paramValues.arg2[0]}</td>
<td>${paramValues.arg2[0]}</td>
<td rowspan="2">配列のrequestパラメータの取得</td>
</tr>
<tr>
<td>\${paramValues.arg2[1]}</td>
<td>${paramValues.arg2[1]}</td>
</tr>
<tr>
<td>\${header.host}</td>
<td>${header.host}</td>
<td>httpリクエストヘッダの取得</td>
</tr>
<tr>
<td>\${headerValues.connection[0]}</td>
<td>${headerValues.connection[0]}</td>
<td>配列のhttpリクエストヘッダの取得</td>
</tr>
<tr>
<td>\${cookie.userid}</td>
<td>-</td>
<td>cookieの取得</td>
</tr>
<tr>
<td>\${initParam.key}</td>
<td>-</td>
<td>web.xml の <jsp-config> に定義された値</td>
</tr>
</table>
</body>
</html>
Java SJC-WC JSP