<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <% String id = (String)session.getAttribute("id"); String center = request.getParameter("center"); %> <% if(id!=null){ %> <%=id %> 님 <button onclick="location.href='Main.jsp?logout=1'">로그아웃</button> <% }else if(center==null){ //center에 값이 존재하는 경우에만 로그인버튼을 띄움. //처리를 안해주고 로그인 버튼을 누를시 LoginForm.jsp로 넘어가면 Top.jsp에 있는 로그인 버튼이 그대로 나옴. %> <button onclick="location.href='Main.jsp?center=LoginForm.jsp'">로그인</button> <% } else{ %> <%} %> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> Center </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <table border="1"> <% response.setCharacterEncoding("UTF-8"); String center = request.getParameter("center"); String logout = request.getParameter("logout"); if(logout!=null){ //id값에 null 값을 넣음 session.setAttribute("id", null); //세션시간 0. 로그아웃 처리 session.setMaxInactiveInterval(0); } if(center==null){ center = "Center.jsp"; } %> <!-- top --> <tr height="50"> <td width="300" align="right"> <jsp:include page="Top.jsp"/> </td> </tr> <!-- center --> <tr height="300"> <td width="300" align="center"> <jsp:include page="<%=center %>"/> </td> </tr> </table> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <form method="post" action="SessionLogin.jsp"> <table> <tr height="50"> <td height="50">로그인</td> <td height="50"><input type="text" name="id"></td> </tr> <tr height="50"> <td height="50">패스워드</td> <td height="50"><input type="password" name="pass"></td> </tr> <tr height="50"> <td height="50"><input type="submit" value="로그인"></td> </tr> </table> </form> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); String id = request.getParameter("id"); String pass = request.getParameter("pass"); session.setAttribute("id", id); session.setAttribute("pass", pass); //세션 유지시간 설정 session.setMaxInactiveInterval(60); //1분간 아이디 유지 response.sendRedirect("Main.jsp"); %> </body> </html>