Set Variable Scope to Session : Session « JSTL « Java Tutorial






<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
  <head>
    <title>Set in Scope Examples</title>
  </head>

  <body>
    <c:set var="test" value="Session Level Value" scope="session" />
    <table border="1">
    <tr>
        <td>
          <b>Default Level</b>
        </td>

        <td>
          <c:out value="${test}" />
        </td>
      </tr>
      <tr>
        <td>
          <b>Page Level</b>
        </td>

        <td>
          <c:out value="${pageScope.test}" />
        </td>
      </tr>

      <tr>
        <td>
          <b>Request Level</b>
        </td>

        <td>
          <c:out value="${requestScope.test}" />
        </td>
      </tr>

      <tr>
        <td>
          <b>Session Level</b>
        </td>

        <td>
          <c:out value="${sessionScope.test}" />
        </td>
      </tr>

      <tr>
        <td>
          <b>Application Level</b>
        </td>

        <td>
          <c:out value="${applicationScope.test}" />
        </td>
      </tr>
    </table>
  </body>
</html>
  Download:  JSTLSetVariableScopeSession.zip( 1,286 k)








24.29.Session
24.29.1.Use JSTL to Deal with Session
24.29.2.Get HTTP Session by using JSTL
24.29.3.View Session Date using JSTL
24.29.4.Update Session Date using JSTL
24.29.5.Set Variable Scope to Session
24.29.6.Remove Attribute From Session