Java/JSTL/Session

Материал из Java эксперт
Перейти к: навигация, поиск

JSTL: Remove the attributes

   <source lang="java">

<%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %> <c:set var="userName" value="Mark" scope="session" /> <html>

 <head>
   <title>Set a scoped attribute</title>
 </head>
 <body>
   This page sets a session-scoped attribute that is removed
   by  page.
 </body>

</html> //removeAttribute.jsp <%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %> <html>

 <head>
   <title>Remove a scoped attribute</title>
 </head>
 <body>
   The session-scoped attribute called userName had a value
   of  <c:out value="${sessionScope.userName}" /> , but it is about
   to be removed!<p/>
   <c:remove var="userName" scope="session" />
   The value is now "<c:out value="${sessionScope.userName}" />"
 </body>

</html>


      </source>
   
  
 
  



JSTL: set attributes

   <source lang="java">

<%@ taglib prefix="c" uri="http://java.sun.ru/jstl/core" %> <html>

 <body>
   This JSP stores the "para" in a session-scoped variable where
   the other JSPs in the web application can access it.
   <p />
   <c:set var="para" value="${41+1}" scope="session"  />
    Click  to view it.
 </body>

</html> //displayAttributes.jsp <%@ taglib prefix="c" uri="http://java.sun.ru/jstl/core" %> <html>

 <head>
   <title>Retrieval of attributes</title>
 </head>
 <body>
   The para is <c:out value="${sessionScope.para}" /> 
</body>

</html>


      </source>