jsp session 세션

2013. 9. 27. 11:09WEB/JSP(JAVA)



반응형

ggariSsesion.html 

<!DOCTYPE html>

<html>

<head>

<meta charset="EUC-KR">

<title>타이틀</title>

</head>

<body>

(아이디,패스워드) 입력해주세요.

<FORM ACTION=Agreement.jsp METHOD =POST>

ID: <INPUT TYPE=TEXT NAME=ID><BR>

PASSWORD: <INPUT TYPE=PASSWORD NAME =PASSWORD><BR>

<INPUT TYPE = SUBMIT VALUE ='확인'>

</FORM>

</body>

</html>



Agreement.jsp

<%@ page language="java" contentType="text/html; charset=EUC-KR"

pageEncoding="EUC-KR"%>

<%

request.setCharacterEncoding("euc-kr");

//html에서부터 값을 받아옴

String id = request.getParameter("ID");

String password = request.getParameter("PASSWORD");


session.setAttribute("ID", id); //세션에 id 저장

session.setAttribute("PASSWORD", password); //세션에 password 저장

%>

<!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>동의</title>

</head>

<body>

<h3>세션에 저장</h3>

회원 세션 아이디 ,패스워드 세션 저장

<form action = result.jsp method=post>

<INPUT TYPE = SUBMIT VALUE ='확인'>

</form>



</body>

</html>



result.jsp

<%@ page language="java" contentType="text/html; charset=EUC-KR"

pageEncoding="EUC-KR"%>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">

<title>결과</title>

</head>

<body>

세션에 저장된 아이디 : <%=session.getAttribute("ID")%> <br> 

세션에 저장된 비번 : <%=session.getAttribute("PASSWORD")%>

</body>

</html>



ggariSsesion.html 

Agreement.jsp

result.jsp




반응형

'WEB > JSP(JAVA)' 카테고리의 다른 글

Eclipse SVN 날짜, 유저 설정  (1) 2013.12.05
[JSP]jsp include  (1) 2013.09.27
[JSP]dynamic web project 만들기  (0) 2013.09.26
JSP page 지시자(Directive)  (0) 2013.09.16
아파치 톰캣 연동 (apache tomcat)  (4) 2013.08.29