================ attributeTestForm.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>
<h1>영역과 속성 테스트</h1>
<form method="post" action="attributeTest_appli.jsp">
<table>
<tr>
<td colspan="2"> Application 영역에 저장할 내용들 </td>
</tr>
<tr>
<td>이름</td>
<td><input type="text" name="name"/></td>
</tr>
<tr>
<td>아이디</td>
<td><input type="text" name="id"/></td>
</tr>
<tr>
<td colspan="2"><center><input type="submit" value="확인"/></center></td>
</tr>
</table>
</form>
</body>
</html>
================ attributeTest_appli.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>
<%= request.getParameter("name") %>님 반갑습니다
<%= request.getParameter("name") %>님의 아이디는 <%= request.getParameter("id") %>입니다.
<%
application.setAttribute("이름", request.getParameter("name"));
application.setAttribute("아이디", request.getParameter("id"));
%>
<form method="post" action="attributeTest_session.jsp">
<table>
<tr>
<td colspan="2"> Session 영역에 저장할 내용들 </td>
</tr>
<tr>
<td>e-mail 주소</td>
<td><input type="text" name="email"/></td>
</tr>
<tr>
<td>집주소</td>
<td><input type="text" name="address"/></td>
</tr>
<tr>
<td>전화번호</td>
<td><input type="text" name="phoneNumber"/></td>
</tr>
<tr>
<td colspan="2"><center><input type="submit" value="확인"/></center></td>
</tr>
</table>
</form>
</body>
</html>
================ attributeTest_session.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>
<h1>영역과 속성 테스트</h1>
<%
session.setAttribute("이메일", request.getParameter("email"));
session.setAttribute("집주소", request.getParameter("address"));
session.setAttribute("전화번호", request.getParameter("phoneNumber"));
%>
<%= application.getAttribute("이름") %>님의 정보가 모두 저장되었습니다.
<a href = "attributeTest_end.jsp">확인하러 가기</a>
</body>
</html>
================ attributeTest_end.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>
<h1>영역과 속성 테스트</h1>
<form >
<table>
<tr>
<td colspan="2"> Application 영역에 저장된 내용들 </td>
</tr>
<tr>
<td>이름</td>
<td><%= application.getAttribute("이름") %></td>
</tr>
<tr>
<td>아이디</td>
<td><%= application.getAttribute("아이디") %></td>
</tr>
</table>
</form>
<form>
<table>
<tr>
<td colspan="2"> Session 영역에 저장된 내용들 </td>
</tr>
<tr>
<td>address</td>
<td><%=session.getAttribute("집주소") %></td>
</tr>
<tr>
<td>tel</td>
<td><%=session.getAttribute("전화번호") %></td>
</tr>
<tr>
<td>email</td>
<td><%=session.getAttribute("이메일") %></td>
</tr>
</table>
</form>
</body>
</html>
'Web > Servlet & JSP' 카테고리의 다른 글
Get방식과 Post 방식의 차이점 (0) | 2016.09.18 |
---|