ex2. application
Posted 2008/10/16 13:50, Filed under: 학과수업들/JSP
<%@ page contentType="text/html; charset=euc-kr" pageEncoding="euc-kr" import="java.io.*" %>
<%
String sData, aData;
sData = "안녕 세션";
aData = "안녕 어플리케이션";
session.setAttribute("sData", sData);
application.setAttribute("aData", aData);
%>
<html>
<head><title> session and application attributes </title></head>
<body>
<center>
세션과 어플리케이션 속성을 설정하였습니다.<br>
<a href="application2_result.jsp">같은 세션에서 확인하기</a>
</center>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=euc-kr" pageEncoding="euc-kr" import="java.util.*" %>
<%
Enumeration atts;
String key;
%>
<html>
<head><title> session and application attributes </title></head>
<body>
<b>세션 속성들 : </b><br>
<%
atts = session.getAttributeNames();
while ( atts.hasMoreElements() ) {
key = (atts.nextElement() ).toString();
%>
<%= key %> = <%= session.getAttribute(key) %> <br>
<% } %>
<br>
<b>어플리케이션 속성들 : </b><br>
<%
atts = application.getAttributeNames();
while ( atts.hasMoreElements() ) {
key = (atts.nextElement() ).toString();
%>
<%= key %> = <%= application.getAttribute(key) %> <br>
<% } %>
<br>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=euc-kr" pageEncoding="euc-kr" import="java.util.*" %>
<html>
<head><title> session and application attributes </title></head>
<body>
<%
session.removeAttribute("sData");
application.removeAttribute("aData");
%>
<b>세션 속성들 : </b><br>
<%
Enumeration atts;
String key;
atts = session.getAttributeNames();
while ( atts.hasMoreElements() ) {
key = (atts.nextElement() ).toString();
%>
<%= key %> = <%= session.getAttribute(key) %> <br>
<% } %>
<br>
<b>어플리케이션 속성들 : </b><br>
<%
atts = application.getAttributeNames();
while ( atts.hasMoreElements() ) {
key = (atts.nextElement() ).toString();
%>
<%= key %> = <%= application.getAttribute(key) %> <br>
<% } %>
<br>
</body>
</html>
Response :
0 Trackback
,
0 Comment
Trackback URL : http://mysilpir.net/trackback/323
