749
No
login.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="./commons/_head.jspf" %>
</head>
<body>
<%@ include file="./commons/_top.jspf" %>
<div class="container">
<div class="row">
<div class="span12">
<section id="typography">
<div class="page-header">
<h1>로그인</h1>
</div>
<form class="form-horizontal" action="/login_action.jsp" method="post">
<c:if test="${not empty errorMessage}">
<div class="control-group">
<label class="error">${errorMessage}</label>
</div>
</c:if>
<div class="control-group">
<label class="control-label" for="userId">사용자 아이디</label>
<div class="controls">
<input type="text" name="userId" value="" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="password">비밀번호</label>
<div class="controls">
<input type="password" id="password" name="password" placeholder="">
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn btn-primary">로그인</button>
</div>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
login_action.jsp
<%@page import="com.slipp.user.User"%>
<%@page import="com.slipp.db.Database"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String userId=request.getParameter("userId");
String password=request.getParameter("password");
User user=Database.findByUserId(userId);
if(User.login(userId, password)){
session.setAttribute("userId", userId);
response.sendRedirect("/");
}
%>
logout.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
session.removeAttribute("userId");
response.sendRedirect("/");
%>
댓글 ( 4)
댓글 남기기