coreタグライブラリで定義されているタグを以下に記載します。
構文1 <c:out value=”値” [escapexml=”{true|false}”] [default=”デフォルト値”] />
構文2 <c:out value=”値” [escapeXml=”{true|false}”]> デフォルト値 </c:out>
<tr> <td><c:out value="${customer.lastName}"/></td> <td><c:out value="${customer.phoneHome}" default="no home phone specified"/></td> <td> <c:out value="${customer.phoneCell}" escapeXml="false"> <font color="red">no cell phone specified</font> </c:out> </td> </tr>
構文1 <c:set value=”値” var=”変数名” [scope=”{page|request|session|application}”]/>
構文2 <c:set var=”変数名” [scope=”{page|request|session|application}”]> 値 </c:set>
構文3 <c:set value=”値” target=”オブジェクト名” property=”プロパティ名”/>
構文4 <c:set target=”オブジェクト名” property=”プロパティ名”> 値 </c:set>
<c:set var="firstName" value="${param.firstName}" />
<c:set var="firstName" value="${firstName}" scope="session" />
<c:set var="localFirstName" value="${sessionScope.firstName}" />
<c:set var="customerTable" scope="application"> <table border="1"> <c:forEach var="customer" items="${customers}"> <tr> <td>${customer.lastName}</td> <td> <c:out value="${customer.address}" default="no address specified"/> </td> <td> <c:out value="${customer.address}"> <font color="red">no address specified</font> </c:out> </td> </tr> </c:forEach> </table> </c:set>
構文1 <c:remove var=”変数名” [scope=”{page|request|session|application}”]/>
<%-- セッションスコープの変数の取得 --%> <c:set var="handleName" value="${sessionScope.handleName}" /> -----何らかの処理----- <%-- 不要なセッションスコープの変数を削除 --%> <c:remove var="handleName" scope="session" />
構文1 <c:forEach[var=”変数名”] items=”オブジェクト名” [varStatus=”ステータス変数名”] [begin=”開始値”] [end=”終了値”] [step=”繰返し処理レベル”]> 繰返し実行される処理 </c:forEach>
構文2 <c:forEach [var=”変数名”] [varStatus=”ステータス変数名”] begin=”開始値” end=”終了値” [step=”繰返し処理レベル”]> 繰返し実行される処理 </c:forEach>
<c:forEach var="i" begin="1" end="10"> ${i} ・ </c:forEach>
<c:forEach var="customer" items="${customers}" varStatus="status"> <tr> <td><c:out value="${status.index}"/></td> <td><c:out value="${status.count}"/></td> <td><c:out value="${status.current.lastName}"/></td> <td><c:out value="${status.current.firstName}"/></td> <td><c:out value="${status.first}"/></td> <td><c:out value="${status.last}"/></td> </tr> <c:if test="${status.last}"> <c:set var="count" value="${status.count}"/> </c:if> </c:forEach>
構文1 <c:forTokens items="文字列" delims="セパレータ" [var="変数名"] [varstatus="ステータス変数名" [begin="開始値" [end="終了値" [step="繰返し処理レベル"> 繰返し実行される処理 </c:forTokens>
<c:forTokens var="i" items="one,two,three,four,five" delims="," begin="3" end="1" varStatus="status"> index: ${status.index} ・ count: ${status.count} ・ item: ${i} </c:forTokens>
構文1 <c:if test=”判定式” var=”変数名” [scope=”{page|request|session|application}”]/> 構文2 <c:if test=”判定式” [var=”変数名”] [scope=”{page|request|session|application}”]> 判定式がtrueの場合に実行される処理 </c:if>
<c:if test="${customer.address.country == 'USA'}"> ${customer}<br> </c:if>
構文1 <c:choose> <c:when test=”判定式”> 判定式がtrueの場合に実行される処理 </c:when> ・・・・・・・・・・・・・・・・・・・・・・ ・・・・・・・・・・・・・・・・・・・・・・ <c:otherwise> どのwhenの判定式もtrueでなかった場合に実行される処理 </c:otherwise> </c:choose>
<c:choose> <c:when test="${customer.address.country == 'USA'}"> <font color="blue"> </c:when> <c:when test="${customer.address.country == 'Canada'}"> <font color="red"> </c:when> <c:otherwise> <font color="green"> </c:otherwise> </c:choose>
構文1 <c:catch [var=”変数名”]> 例外が発生する可能性のある処理 </c:catch>
構文1 <c:import url=”インポートするコンテンツのURL” [context=”コンテキストのURL”] [var=”変数名”] [scope=”{page|request|session|application}”] [charEncoding=”エンコード方式”]> インポートされるコンテンツに関する処理 <c:param>タグの処理 </c:import> 構文2 <c:import url=”インポートするコンテンツのURL” [context=”コンテキストのURL”] varReader=”Reader型の変数名” [charEncoding=”エンコード方式”]> Reader型の変数に関する処理 </c:import>
<c:import var="cnn" url="http://www.cnn.com/cnn.rss"/>
構文1 <c:url value=”URLエンコードされるURL” [context=”コンテキストのURL”] [var=”変数名”] [scope=”{page|request|session|application}”]/> 構文2 <c:url value=”URLエンコードされるURL” [context=”コンテキストのURL”] [var=”変数名”] [scope=”{page|request|session|application}”]> <c:param>タグの処理 </c:url>
<tr> <td>"base", param=ABC</td> <td> <c:url value="base"> <c:param name="param" value="ABC"/> </c:url> </td> </tr>
構文1 <c:redirect url=”リダイレクト先のURL” [context=”コンテキストのURL”]/> 構文2 <c:redirect url=”リダイレクト先のURL” [context=”コンテキストのURL”]/> <c:param>タグの処理 </c:redirect>
構文1 <c:param name=”パラメータ名” value=”パラメータ値”/> 構文2 <c:param name=”パラメータ名”/> パラメータ値 </c:param>