본문 바로가기

프로그래머/JSP

session

 

<%@ page info="ex05-04.jsp" language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

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

<title>session 내장객체 예제(1)</title>

</head>

<body>

<h4>session 내장객체 예제(1)</h4>

아이디를 입력하세요...

<form method="post">

<table border = "1">

<tr>

<td>아이디 : <input type = "text" name = "id">

<input type = "submit" value = "로그인">

</tr>

</table>

</form>

<%

String user = "";

if (request.getParameter("id") != null) {

user = request.getParameter("id");

session.setAttribute("id", user);

response.sendRedirect("ex05-04-1.jsp");

}

%>

</body>

</html>

 

 

<%@ page info="ex05-04-1.jsp" language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="UTF-8"%>

<!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=UTF-8">

<title>session 내장객체 예제(2)</title>

</head>

<body>

<h4>session 내장객체 예제(2)</h4>

당신의 세션 ID

<%= session.getAttribute("id") %> 입니다.<br>

</body>

</html>

'프로그래머 > JSP' 카테고리의 다른 글

JSP Tag  (0) 2015.03.17