20220328 º¹½À
selectDB -> Å×ÀÌºí¿¡¼ Àüü Ç׸ñ °¡Á®¿À±â.
getDB -> Å×ÀÌºí¿¡¼ where Á¶°Ç¿¡ ÇØ´çÇÏ´Â ·¹ÄÚµå ÇÑ ÁÙ¸¸ °¡Á®¿À±â.
¼¼¼Ç ! -> ·Î±×ÀÎ !
¸ðµç ÆäÀÌÁö¿¡ ³ª¿À´Â º¯¼ö ¸¸µé±â (·Î±×¾Æ¿ô/ÆäÀÌÁö ´Ý±â Àü±îÁö Ç×»ó À¯È¿ÇÔ)
session.setAtrribute(String name, Object);
session.removeAttribute("uid");
session.invalidate();
session.getAttribute("uid");
ex)
header.jsp
<% if(session.getAttribute("uid")==null){ %>
<form class="d-flex" method="post" action="/lego3/user/login_form.jsp">
<button type="submit">Sign In</button>
</form>
<% }else{ %>
<form class="d-flex" method="post" action="/lego3/user/user_ctl.jsp">
<input type="hidden" name="command" value="logout">
<button type="submit">Log Out</button>
</form>
<% } %>
lego_list.jsp
<%
String uid=(String)session.getAttribute("uid");
if(uid==null){
out.println("Please sign in to use LEGO Management System");
}else{
%>
user_ctl.jsp
case "login" :
if( mb.login(member) ){
Member amember = mb.getDB(member.getUid());
session.setAttribute("uid", amember.getUid());
session.setAttribute("name", amember.getName());
session.setAttribute("passwd", amember.getPasswd());
session.setAttribute("email", amember.getEmail());
response.sendRedirect("/lego3/index.jsp");
}else{
out.println("·Î±×ÀÎ ½ÇÆÐ ...");
out.println("<script>alert('·Î±×ÀÎ ½ÇÆÐÀÔ´Ï´Ù. ´Ù½Ã È®ÀÎÇØ ÁÖ¼¼¿ä');history.go(-1);</script>");
}
break;