package member.servlet;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import member.dto.MemberDTO;
public class GetLoginMemberInfoServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public GetLoginMemberInfoServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession httpSession = request.getSession();
RequestDispatcher rdp =null;
MemberDTO memberDTO=(MemberDTO)httpSession.getAttribute("memberDTO");
if(memberDTO==null){
request.setAttribute("error_message", "로그인한 정보가 없습니다.");
rdp = request.getRequestDispatcher("/login_form.jsp");
}else{
rdp = request.getRequestDispatcher("/res/member_details.jsp");
}
rdp.forward(request, response);
}
}
<%@page import="member.dto.MemberDTO"%>
<%@ 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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
MemberDTO memberDTO = (MemberDTO)session.getAttribute("memberDTO");
%>
아이디 : <%=memberDTO.getId() %><br>
이름 : <%=memberDTO.getName() %><br>
주민번호 : <%=memberDTO.getRegisterNumber() %><br>
마일리지 : <%=memberDTO.getMileage() %><br>
<a href="/member_servlet/index.html">메인페이지</a>
<a href="/member_servlet/login_form.jsp">로그인하기</a>
</body>
</html>