본문 바로가기

개발하자/JSP&Servlet

emp테이블의 ename을 출력하고 클릭하면 상세내용나오게 하기

db1.jsp

============================================================

<%@page import="kr.co.seoulit.emp.to.EmpBean"%>
<%@page import="java.util.List"%>
<%@page import="kr.co.seoulit.emp.dao.EmpDAOImpl"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
 pageEncoding="EUC-KR"%>
<!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=EUC-KR">
<title>Insert title here</title>
<style type="text/css">
 td {border:3px solid navy; }
</style>
</head>
<body><table>
<%
 List<EmpBean> list=EmpDAOImpl.getInstance().selectEmpList();
 for(EmpBean bean:list){
 out.println("<tr>");
 out.println("<td>"+"<a href=db2.jsp?id="+bean.getEname()+">"+bean.getEname()+"</td>");
 out.println("</tr>");
 }
%>
</table></body>
</html>

 

 

db2.jsp

==================================================================

<%@page import="kr.co.seoulit.emp.to.EmpBean"%>
<%@page import="java.util.List"%>
<%@page import="kr.co.seoulit.emp.dao.EmpDAOImpl"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
 pageEncoding="EUC-KR"%>
<!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=EUC-KR">
<title>Insert title here</title>
<style type="text/css">
 td {border:3px solid navy; }
</style>
</head>
<body><table>
<%
 EmpBean bean=EmpDAOImpl.getInstance().selectEmp(request.getParameter("id"));

if(bean!=null){
 out.println("<tr>");
out.println("<td>"+bean.getEmpno()+"</td>");
 out.println("<td>"+bean.getJob()+"</td>");
 out.println("<td>"+bean.getMgr()+"</td>");
 out.println("<td>"+bean.getHiredate()+"</td>");
 out.println("<td>"+bean.getLoc()+"</td>");
 out.println("</tr>");
 }
%>
</table></body>
</html>