countTest.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="c1" class="test.Count" scope="page"></jsp:useBean>
<jsp:useBean id="c2" class="test.Count" scope="session"></jsp:useBean>
<jsp:useBean id="c3" class="test.Count"' scope="application"></jsp:useBean>
<%
c1.incCount();
c2.incCount();
c3.incCount();
%>
page : <%=c1.getCount() %><br>
session : <%=c2.getCount() %><br>
application : <%=c3.getCount() %><br>
<input type="button" value="다음" onClick="javascript
</body>
</html>
countTest2.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="c1" class="test.Count" scope="page"></jsp:useBean>
<jsp:useBean id="c2" class="test.Count" scope="session"></jsp:useBean>
<jsp:useBean id="c3" class="test.Count"' scope="application"></jsp:useBean>
<%
c1.incCount();
c2.incCount();
c3.incCount();
%>
page : <%=c1.getCount() %><br>
session : <%=c2.getCount() %><br>
application : <%=c3.getCount() %><br>
<input type="button" value="이전" onClick="javascript
</body>
</html>
Count.java
package test;
public class Count {
private int count;
public void incCount(){
count++;
}
public int getCount(){
return count;
}
}
'Programing > JSP' 카테고리의 다른 글
Servlet - 공지파일 예제 (0) | 2008.07.29 |
---|---|
Servlet - WAS 구동과정 및 Servlet의 생명 주기 (1) | 2008.07.29 |
JSP - Bean활용 (0) | 2008.07.29 |
JSP - forward (2) | 2008.07.29 |
JSP - include (0) | 2008.07.29 |