CookieLogin.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>Cookie Login</title>
</head>
<body>
<form action="SessionLogin.jsp">
<table>
<tr>
<td>id</td>
<td><input type="text" name="id"></td>
</tr>
<tr>
<td>pw</td>
<td><input type="text" name="pw"></td>
</tr>
<tr>
<td><input type="submit" value="Send"></td>
</tr>
</table>
</form>
</body>
</html>
SessionLogin.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>Session Login</title>
</head>
<body>
<%
String id_ = "jiniusman";
String pw_ = "blogspot";
String id = request.getParameter("id");
String pw = request.getParameter("pw");
if(id.equals(id_) && pw.equals(pw_))
{
session.setAttribute("identification", id_);
session.setAttribute("password", pw_);
response.sendRedirect("SessionLogin1.jsp");
session.setMaxInactiveInterval(10);
}
else
{
%>
<script>
alert("fail");
history.go(-1);
</script>
<%
//response.sendRedirect("CookieLogin.jsp");
}
%>
</body>
</html>
SessionLogin1.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>Session Login</title>
</head>
<body>
<%
String id = session.getAttribute("identification").toString();
String pw = session.getAttribute("password").toString();
%>
id : <%=id%><br>
pw : <%=pw%><br>
<a href="Login.jsp">log-in</a>
</body>
</html>
Login.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>Login</title>
</head>
<body>
<form action="SessionLogin.jsp">
<table>
<tr>
<td>id</td>
<td>
<input type="text" name="id" value="<%=session.getAttribute("identification")%>">
</td>
</tr>
<tr>
<td>pw</td>
<td>
<input type="text" name="pw" value="<%=session.getAttribute("password")%>">
</td>
</tr>
<tr>
<td><input type="submit" value="Send"></td>
</tr>
</table>
</form>
</body>
</html>
result)
댓글 없음:
댓글 쓰기