본문 바로가기

DB/ORACLE

해당 EMPNO의 상세 페이지

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"
    import="webprj.a05_database.A01_database"
    import="webprj.a05_database.Emp"
    %>
<%String path=request.getContextPath();
int empno = Integer.parseInt( request.getParameter("empno") );
 
%>    
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="<%=path %>/a00_com/a00_com.css" >
<script src="<%=path %>/a00_com/jquery-3.4.1.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $("h2").html("<%=empno%>의 상세화면");
        
        $("#uptBtn").click(function(){
            location.href="";
        });
        $("#delBtn").click(function(){
            location.href="";
        });
        $("#schBtn").click(function(){
            location.href="a02_empSch.jsp";
        });
    });
</script>
</head>
<%
A01_database db = new A01_database();
Emp emp = db.getEmp(empno);
%>
<body>
    <h2></h2>
    <table>
        <tr><th>사원번호</th><td><%=emp.getEmpno() %></td></tr>
        <tr><th>사원명</th><td><%=emp.getEname() %></td></tr>
        <tr><th>직책</th><td><%=emp.getJob() %></td></tr>
        <tr><th>관리자번호</th><td><%=emp.getMgr() %></td></tr>
        <tr><th>입사일</th><td><%=emp.getHiredate() %></td></tr>
        <tr><th>급여</th><td><%=emp.getSal() %></td></tr>
        <tr><th>보너스</th><td><%=emp.getComm() %></td></tr>
        <tr><th>부서번호</th><td><%=emp.getDeptno() %></td></tr>
        <tr><td colspan="2"><input type= "button" value ="수정" id ="uptBtn"/>
                            <input type= "button" value ="삭제" id ="delBtn"/>
                            <input type= "button" value ="메인화면" id ="schBtn"/></td></tr>
    </table>     
</body>
</html>
cs

 

이 jsp의 기본주소는 http://localhost:7080/webprj/a05_database/a02_empDetail.jsp?인데

Line6의 request.getParameter에 의해 empno="입력값"이 붙어서 최종적으로

http://localhost:7080/webprj/a05_database/a02_empDetail.jsp?empno=### 이 된다.

 

다음 Line35에서 getEmp()메서드를 통해 다음과 같은sql문에 의해 ###=empno의 모든 값을 가져온다.

1
2
3
            String sql = "select * \r\n"+
                         "from emp01\r\n"+
                         "where empno = ?";
cs

가져온 모든 값은 Line39에 차려진 테이블 위에 담겨 보여진다.

 

'DB > ORACLE' 카테고리의 다른 글

method=post방식 get방식  (0) 2019.09.05
DATABASE 처리 메서드를 구현  (0) 2019.09.03
DB 모르는 애들 공부 - Statement, executeQuery, executeUpdate  (0) 2019.09.01
아라보기  (0) 2019.08.31
재설치 후 scott 계정 가져오기  (0) 2019.08.13