세션 로그인1
<%@ page contentType="text/html; charset=EUC-KR"%>
<html>
<head>
<TITLE>로그인 화면</TITLE>
</HEAD>
<BODY>
<form action="9-7.jsp" method="post">
아이디 <input type="text" name="id"><br>
비밀번호 <input type="password" name="pw"><br>
<input type="submit" value="확인">
</form>
</BODY>
</HTML>
세션 로그인2
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<html>
<head>
<TITLE>로그인 처리 화면</TITLE>
</head>
<body>
<%
String id = request.getParameter("id");
String pw = request.getParameter("pw");
// null 체크 추가
if (id != null && pw != null) {
if (id.equals("admin") && pw.equals("pass")) {
session.setAttribute("LOGIN", id);
out.print("<h2>로그인 성공</h2>");
} else {
out.print("<h2>로그인 실패</h2>");
}
} else {
out.print("<h2>아이디와 비밀번호를 입력하세요</h2>");
}
%>
<H3>
<A HREF="9-8.jsp">로그인확인</A>
</H3>
</body>
</html>
세션 로그인3
<%@ page contentType="text/html; charset=EUC-KR" %>
<html>
<head>
<TITLE>로그인 확인 화면</TITLE>
</head>
<body>
<%
String id = (String)session.getAttribute("login");
if(id != null && id.equals("admin")) {
out.print("<h2>로그인 한 상태입니다. ID = " + id + "</h2>");
out.print("<h3><a href=9-9.jsp>로그아웃</a></h3>");
} else {
out.print("<h2>로그인 안한 상태입니다.</h2>");
out.print("<h3><a href=9-6.jsp>로그인</a></h3>");
}
%>
</body>
</html>
세션 로그인4
<%@ page contentType="text/html; charset=EUC-KR"%>
<%@ page session="true"%>
<%
session.invalidate();
%>
<html>
<head>
<TITLE>로그아웃 화면</TITLE>
</head>
<BODY>
<H2>로그아웃 되었습니다.</H2>
</BODY>
</HTML>
세상을 링크하라!!! 모든 링크를 한 자리에...
링크닷컴: https://linkdotcom.mycafe24.com/
유용한 링크, 링크닷컴 #무료 #링크사이트 #링크사이트
컴퓨터 및 일반 유용한 링크들을 모아 놓았습니다. 지금 바로 확인하세요!
linkdotcom.mycafe24.com