Java/JSTL/Session — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 06:17, 1 июня 2010
JSTL: Remove the attributes
<%@ 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 <b>userName</b> had a value
of <b> <c:out value="${sessionScope.userName}" /> </b>, 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>
JSTL: set attributes
<%@ 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}" /> <br/>
</body>
</html>