반응형

참고사이트 : https://all-record.tistory.com/112


1.JoinForm.jsp : 회원가입화면

2.join_style.css : JoinForm과 JoinPro는 동일한 css를 사용하므로 별도로 파일 분리

3.DBConnection.java : DB커넥션을 담당하는 클래스 (JNDI를 통해 커넥션을 가져옴)

4.MemberBean.java : 회원정보를 전달할 자바빈

5.MemberDAO.java : JSP_MEMBER 테이블의 데이터 처리를 담당하는 클래스

6.JoinPro.jsp : 파라미터 값을 넘겨받아 회원가입을 처리하는 JSP



그외

-web.xml : JNDI 리소스 사용 설정을 위한 xml파일

-ojdbc6.jar : 오라클 JDBC 드라이버

-tomcat-dbcp.jar : 커넥션 풀 관련 라이브러


6.JoinPro.jsp

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%> 
    
<%-- 자바빈 클래스 import --%>      
<%@ page import="jsp.member.model.MemberBean" %>  
<%-- DAO import --%>   
<%@ page import="jsp.member.model.MemberDAO" %> 
 
<html>
<head>
    <title>회원가입 처리 JSP</title>
    
    <!-- css 파일 분리 -->
    <link href='../../css/join_style.css' rel='stylesheet' style='text/css'/>
    
</head>
<body>
    <%-- JoinForm.jsp에서 입력한 정보를 넘겨 받아 처리한다. --%>
    <% 
        // 한글 깨짐을 방지하기 위한 인코딩 처리
        request.setCharacterEncoding("euc-kr"); 
    %>
    
    <%-- 자바빈 관련 액션태그 사용 --%>
    <jsp:useBean id="memberBean" class="jsp.member.model.MemberBean" />
    <jsp:setProperty property="*" name="memberBean"/>    
   <%--  <jsp:setProperty name="memberBean" param="id" property="id" />
    --%> <%
    //System.out.println("빈출력 : " + memberBean);    
    MemberDAO dao = MemberDAO.getInstance();
        //out.print("dao 테스트" + dao);
        // 회원정보를 담고있는 memberBean을 dao의 insertMember() 메서드로 넘긴다.
        // insertMember()는 회원 정보를 JSP_MEMBER 테이블에 저장한다.
        dao.insertMember(memberBean);
    %>
    
    <div id="wrap">
        <br><br>
        <b><font size="5" color="gray">회원가입 정보를 확인하세요.</font></b>
        <br><br>
        <font color="blue"><%=memberBean.getName() %></font>님 가입을 축하드립니다.
        <br><br>
        
        <%-- 자바빈에서 입력된 값을 추출한다. --%>
        <table>
            <tr>
                <td id="title">아이디</td>
                <td><%=memberBean.getId() %></td>
            </tr>
                        
            <tr>
                <td id="title">비밀번호</td>
                <td><%=memberBean.getPassword() %></td>
            </tr>
                    
            <tr>
                <td id="title">이름</td>
                <td><%=memberBean.getName() %></td>
            </tr>
                    
            <tr>
                <td id="title">성별</td>
                <td><%=memberBean.getGender()%></td>
            </tr>
                    
            <tr>
                <td id="title">생일</td>
                <td>
                    <%=memberBean.getBirthyy() %>년 
                    <%=memberBean.getBirthmm() %>월 
                    <%=memberBean.getBirthdd() %>
                </td>
            </tr>
                    
            <tr>
                <td id="title">이메일</td>
                <td>
                    <%=memberBean.getMail1() %>@<%=memberBean.getMail2() %>
                </td>
            </tr>
                    
            <tr>
                <td id="title">휴대전화</td>
                <td><%=memberBean.getPhone() %></td>
            </tr>
            <tr>
                <td id="title">주소</td>
                <td>
                    <%=memberBean.getAddress() %>
                </td>
            </tr>
        </table>
        
        <br>
        <input type="button" value="확인">
    </div>
</body>
</html>
 
 
 
cs


반응형
반응형

참고사이트 : https://all-record.tistory.com/114?category=733042






1.JoinForm.jsp : 회원가입화면

2.join_style.css : JoinForm과 JoinPro는 동일한 css를 사용하므로 별도로 파일 분리

3.DBConnection.java : DB커넥션을 담당하는 클래스 (JNDI를 통해 커넥션을 가져옴)

4.MemberBean.java : 회원정보를 전달할 자바빈

5.MemberDAO.java : JSP_MEMBER 테이블의 데이터 처리를 담당하는 클래스

6.JoinPro.jsp : 파라미터 값을 넘겨받아 회원가입을 처리하는 JSP



그외

-web.xml : JNDI 리소스 사용 설정을 위한 xml파일

-ojdbc6.jar : 오라클 JDBC 드라이버

-tomcat-dbcp.jar : 커넥션 풀 관련 라이브러



3.DBConnection.java(JNDI를 통해 커넥션을 가져옴)

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
package jsp.util;
 
import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
 
// 커넥션을 얻어오는 클래스 - JNDI
public class DBConnection 
{
    public static Connection getConnection() throws SQLException, NamingException, 
    ClassNotFoundException{
            Context initCtx = new InitialContext();
            
            //initCtx의 lookup메서드를 이용해서 "java:comp/env" 에 해당하는 객체를 찾아서 evnCtx에 삽입
            Context envCtx = (Context) initCtx.lookup("java:comp/env");
 
            //System.out.println("커넥션 된거냐 ??? " + envCtx);
            //envCtx의 lookup메서드를 이용해서 "jdbc/orcl"에 해당하는 객체를 찾아서 ds에 삽입
            DataSource ds = (DataSource) envCtx.lookup("jdbc/orcl");
 
            //System.out.println("커넥션 된거냐 ??? " + ds);
            //getConnection메서드를 이용해서 커넥션 풀로 부터 커넥션 객체를 얻어내어 conn변수에 저장
            Connection conn = ds.getConnection();
            //System.out.println("커넥션 된거냐 ??? " + conn);
            return conn;
    }
}    
 
 
 
cs



4.MemberBean.java (회원정보를 전달할 자바빈)

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package jsp.member.model;
 
import java.sql.Timestamp;
 
public class MemberBean {
    
        private String id;            // 아이디
        private String password;     // 비밀번호
        private String name;        // 이름
        private String gender;        // 성별
        private String birthyy;        // 생일 - 년
        private String birthmm;        // 생일 - 월
        private String birthdd;        // 생일 - 일
        private String mail1;        // 이메일 - @ 앞부분
        private String mail2;        // 이메일 - @ 뒷부분
        private String phone;        // 전화
        private String address;        // 주소
        private Timestamp reg;        // 가입일
        
        public String getId() {
            return id;
        }
        public void setId(String id) {
            this.id = id;
        }
        public String getPassword() {
            return password;
        }
        public void setPassword(String password) {
            this.password = password;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public String getGender() {
            return gender;
        }
        public void setGender(String gender) {
            this.gender = gender;
        }
        public String getBirthyy() {
            return birthyy;
        }
        public void setBirthyy(String birthyy) {
            this.birthyy = birthyy;
        }
        public String getBirthmm() {
            return birthmm;
        }
        public void setBirthmm(String birthmm) {
            this.birthmm = birthmm;
        }
        public String getBirthdd() {
            return birthdd;
        }
        public void setBirthdd(String birthdd) {
            this.birthdd = birthdd;
        }
        public String getMail1() {
            return mail1;
        }
        public void setMail1(String mail1) {
            this.mail1 = mail1;
        }
        public String getMail2() {
            return mail2;
        }
        public void setMail2(String mail2) {
            this.mail2 = mail2;
        }
        public String getPhone() {
            return phone;
        }
        public void setPhone(String phone) {
            this.phone = phone;
        }
        public String getAddress() {
            return address;
        }
        public void setAddress(String address) {
            this.address = address;
        }
        public Timestamp getReg() {
            return reg;
        }
        public void setReg(Timestamp reg) {
            this.reg = reg;
        }
       // @Override
        //public String toString() {
        //    return "MemberBean [id=" + id + ", password=" + password + ", name=" + name + ", gender=" + gender
        //            + ", birthyy=" + birthyy + ", birthmm=" + birthmm + ", birthdd=" + birthdd + ", mail1=" + mail1
        //            + ", mail2=" + mail2 + ", phone=" + phone + ", address=" + address + ", reg=" + reg + "]";
        //}
    
    
}
cs


5.MemberDAO.java (JSP_MEMBER 테이블의 데이터 처리를 담당하는 클래스)

DAO란 DB와 관련된 CRUD(등록,검색,수정,삭제) 작업을 처리한다. DAO는 일반적으로 DB테이블 당 1개를 작성한다.

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package jsp.member.model;
 
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Date;
import javax.naming.NamingException;
 
import jsp.util.DBConnection;
 
 
/* Data Access Object
 * 테이블 당 한개의 DAO를 작성한다.
 * 
 * JSP_MEMBER 테이블과 연관된 DAO로
 * 회원 데이터를 처리하는 클래스이다.
 */
public class MemberDAO
{
    private static MemberDAO instance;
    
    // 싱글톤 패턴
    private MemberDAO(){}
    public static MemberDAO getInstance(){
        if(instance==null)
            instance=new MemberDAO();
        return instance;
    }
    
    // String -> Date로 변경하는 메서드
    // 문자열로된 생년월일을 Date로 변경하기 위해 필요
    // java.util.Date클래스로는 오라클의 Date형식과 연동할 수 없다.
    // Oracle의 date형식과 연동되는 java의 Date는 java.sql.Date 클래스이다.
    public Date stringToDate(MemberBean member)
    {
        String year = member.getBirthyy();
        String month = member.getBirthmm();
        String day = member.getBirthdd();
        
        System.out.println(member.getBirthyy());
        System.out.println(member.getBirthmm());
        System.out.println(member.getBirthdd());
        //Date birthday = Date.valueOf("2016"+"-"+"11"+"-"+"22");
        
        /*
         * 123 01 11
         */
         Date birthday = Date.valueOf(year+"-"+month+"-"+day);
        
        return birthday;
        
    } // end stringToDate()
    
    // 회원정보를 JSP_MEMBER 테이블에 저장하는 메서드
    public void insertMember(MemberBean member) throws SQLException
    {
        Connection conn = null;
        PreparedStatement pstmt = null;
       // System.out.println("멤버출력하기 : "  +member);
       // System.out.println("멤버출력하기 : "  +member.toString());
 
        
        try {
            // 커넥션을 가져온다.
            conn = DBConnection.getConnection();
            
            System.out.println("커넥션 출력 : " + conn);
            
            // 자동 커밋을 false로 한다.
            conn.setAutoCommit(false);
            
            // 쿼리 생성한다.
            // 가입일의 경우 자동으로 세팅되게 하기 위해 sysdate를 사용
            StringBuffer sql = new StringBuffer();
            sql.append("insert into JSP_MEMBER values");
            sql.append("(?, ?, ?, ?, ?, ?, ?, ?, sysdate)");        
           // stringToDate(member);
            /* 
             * StringBuffer에 담긴 값을 얻으려면 toString()메서드를
             * 이용해야 한다.
             */
            pstmt = conn.prepareStatement(sql.toString());
            pstmt.setString(1, member.getId());
            pstmt.setString(2, member.getPassword());
            pstmt.setString(3, member.getName());
            pstmt.setString(4, member.getGender());
            pstmt.setDate(5, stringToDate(member));
            pstmt.setString(6, member.getMail1()+"@"+member.getMail2());
            pstmt.setString(7, member.getPhone());
            pstmt.setString(8, member.getAddress());
            
            // 쿼리 실행
            pstmt.executeUpdate();
            // 완료시 커밋
            conn.commit(); 
            
        } catch (ClassNotFoundException | NamingException | SQLException sqle) {
       // } catch (Exception E) {
            //E.printStackTrace();
                
              // 오류시 롤백 conn.rollback();
              
              throw new RuntimeException(sqle.getMessage());
             
            } finally {
            // Connection, PreparedStatement를 닫는다.
            try{
                if ( pstmt != null ){ pstmt.close(); pstmt=null; }
                if ( conn != null ){ conn.close(); conn=null;    }
            }catch(Exception e){
                throw new RuntimeException(e.getMessage());
            }
        } // end try~catch 
    } // end insertMember()
}
 
 
 
cs


*싱글톤패턴(SINGLETON PATTERN)

싱글턴패턴이란 인스턴스를 하나만 만들어 사용하기 위한 패턴이다. 커넥션 풀, 스레드 풀, 디바이스 설정 객체 등의 경우 인스턴스를 여러개 만들게 되면 자원을 낭비하게 되거나 버그를 발생시킬 수 있으므로 오직 하나만 생성하고 그 인스턴스를 사용하도록 하는것이 목적이다.

애플리케이션이 시작될 때 어떤 클래스가 최초 한번만 메로리를 할당하고 그 메모리에 인스턴스를 만들어 사용하는 디자인패턴.


 private MemberDAO(){}

    public static MemberDAO getInstance(){
        if(instance==null)
            instance=new MemberDAO();
        return instance;




* try catch(예외 처리 코드)

1
2
3
4
5
6
7
8
9
10
try{
    //에러가 발생할 수 있는 코드
    throw new Exception(); //강제 에러 출력 
}catch (Exception e){
    //에러시 수행
     e.printStackTrace(); //오류 출력(방법은 여러가지)
     throw e; //최상위 클래스가 아니라면 무조건 던져주자
}finally{
    //무조건 수행
cs





반응형
반응형

참고사이트 : https://all-record.tistory.com/114?category=733042



1.JoinForm.jsp : 회원가입화면

2.join_style.css : JoinForm과 JoinPro는 동일한 css를 사용하므로 별도로 파일 분리

3.DBConnection.java : DB커넥션을 담당하는 클래스

4.MemberBean.java : 회원정보를 전달할 자바빈

5.MemberDAO.java : JSP_MEMBER 테이블의 데이터 처리를 담당하는 클래스

6.JoinPro.jsp : 파라미터 값을 넘겨받아 회원가입을 처리하는 JSP



그외

-web.xml : JNDI 리소스 사용 설정을 위한 xml파일

-ojdbc6.jar : 오라클 JDBC 드라이버

-tomcat-dbcp.jar : 커넥션 풀 관련 라이브러


1. JoinForm.jsp


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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<html>
<head>
    <title>회원가입 화면</title>
    
    <!-- css 파일 분리 -->
    <link href='../../css/join_style.css' rel='stylesheet' style='text/css'/>
 
    <script type="text/javascript">
    
        // 필수 입력정보인 아이디, 비밀번호가 입력되었는지 확인하는 함수
        function checkValue()
        {
            if(!document.userInfo.id.value){
                alert("아이디를 입력하세요.");
                return false;
            }
            
            if(!document.userInfo.password.value){
                alert("비밀번호를 입력하세요.");
                return false;
            }
            
            // 비밀번호와 비밀번호 확인에 입력된 값이 동일한지 확인
            if(document.userInfo.password.value != document.userInfo.passwordcheck.value ){
                alert("비밀번호를 동일하게 입력하세요.");
                return false;
            }
        }
    </script>
    
</head>
<body>
    <!-- div 왼쪽, 오른쪽 바깥여백을 auto로 주면 중앙정렬된다.  -->
    <div id="wrap">
        <br><br>
        <b><font size="6" color="gray">회원가입</font></b>
        <br><br><br>
        
        
        <!-- 입력한 값을 전송하기 위해 form 태그를 사용한다 -->
        <!-- 값(파라미터) 전송은 POST 방식, 전송할 페이지는 JoinPro.jsp -->
        <form method="post" action="../pro/JoinPro.jsp" name="userInfo" onsubmit="return checkValue()">
            <table>
                <tr>
                    <td id="title">아이디</td>
                    <td>
                        <input type="text" name="id" maxlength="50">
                        <input type="button" value="중복확인" >    
                    </td>
                </tr>
                        
                <tr>
                    <td id="title">비밀번호</td>
                    <td>
                        <input type="password" name="password" maxlength="50">
                    </td>
                </tr>
                
                <tr>
                    <td id="title">비밀번호 확인</td>
                    <td>
                        <input type="password" name="passwordcheck" maxlength="50">
                    </td>
                </tr>
                    
                <tr>
                    <td id="title">이름</td>
                    <td>
                        <input type="text" name="name" maxlength="50">
                    </td>
                </tr>
                    
                <tr>
                    <td id="title">성별</td>
                    <td>
                        <input type="radio" name="gender" value="남" checked>
                        <input type="radio" name="gender" value="여" checked>
                    </td>
                </tr>
                    
                <tr>
                    <td id="title">생일</td>
                    <td>
                        <input type="text" name="birthyy" maxlength="4" placeholder="년(4자)" size="6" >
                        <select name="birthmm">
                            <option value=""></option>
                            <option value="01" >1</option>
                            <option value="02" >2</option>
                            <option value="03" >3</option>
                            <option value="04" >4</option>
                            <option value="05" >5</option>
                            <option value="06" >6</option>
                            <option value="07" >7</option>
                            <option value="08" >8</option>
                            <option value="09" >9</option>
                            <option value="10" >10</option>
                            <option value="11" >11</option>
                            <option value="12" >12</option>
                        </select>
                        <input type="text" name="birthdd" maxlength="2" placeholder="일" size="4" >
                    </td>
                </tr>
                    
                <tr>
                    <td id="title">이메일</td>
                    <td>
                        <input type="text" name="mail1" maxlength="50">@
                        <select name="mail2">
                            <option>naver.com</option>
                            <option>daum.net</option>
                            <option>gmail.com</option>
                            <option>nate.com</option>                        
                        </select>
                    </td>
                </tr>
                    
                <tr>
                    <td id="title">휴대전화</td>
                    <td>
                        <input type="text" name="phone" />
                    </td>
                </tr>
                <tr>
                    <td id="title">주소</td>
                    <td>
                        <input type="text" size="50" name="address"/>
                    </td>
                </tr>
            </table>
            <br>
            <input type="submit" value="가입"/>  <input type="button" value="취소">
        </form>
    </div>
</body>
</html>
 



2. join_style.css

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
        #wrap{
            width:700px;
            margin-left:auto; 
            margin-right:auto;
            text-align:center;
        }
        
        table{
            margin-left:auto; 
            margin-right:auto;
            border:3px solid white
        }
        
        td{
            border:1px solid gray
        }
        
        #title{
            background-color:white
        }
 
cs









<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>

  * page 디렉티브 <%@ page%>

 

속성명
속성의 기본값 사용법 속성 설명 
info  info="설명.." 페이지를 설명해 주는 문자열을 지정하는 속성 
language "java" language="java" JSP 페이지의 스크립트 요소에서 사용할 언어를 지정하는 속성 
contentType "text/html;charset=ISO-8859-1" contentType="text/html;charset=utf-8" JSP 페이지가 생성할 문서의 타입을 지정하는 속성 
extends  extends="system.MasterClass" 자신이 상속 받을 클래스를 지정할 때 사용하는 속성 
import  import="java.util.Vector"다른 패키지에 있는 클래스를 가져다 쓸 때 사용하는 속성 
import="java.util.*" 
session "true" session="true" HttpSession을 사용할지 여부를 지정하는 속성 
buffer "8kb" buffer="10kb" buffer="none" JSP 페이지의 출력 버퍼의 크기를 지정하는 속성 
autoFlush "true" autoFlush="false" 출력 버퍼가 다 찰 경우에 저장되어 있는 내용의 처리를 설정 하는 속성 
 isThreadSafe"true" isThreadSafe="true" 현 페이지에 다중쓰레드를 허용할지 여부를 설정하는 속성 
errorPage  errorPage="error/fail.jsp" 에러 발생 시 에러를 처리할 페이지를 지정하는 속성 
isErrorPage "false" isErrorPage="false" 해당 페이지를 에러 페이지로 지정하는 속성 
pageEncoding "ISO-8859-1" pageEncoding="UTF-8" 해당 페이지의 문자 인코딩을 지정하는 속성 
 isELignoredJSP 버전 및 설정에 따라 다르다.  isELIgnored="true"표현 언어(EL)에 대한 지원 여부를 설정하는 속성 


따라서 jsp스크립트 요소에서 사용할 언어가 java이며, jsp페이지가 생성할 문서의 타입은 text/html이고, 문자 인코딩속성은 EUC-KR 입니다.


    <link href='../../css/join_style.css' rel='stylesheet' style='text/css'/>


HTML에 CSS를 적용시키는 방법
장점은 여러 HTML 문서에 사용할 수 있다는 것입니다. style.css를 적용시키고 싶은 문서에 <link> 태그로 연결만 해주면 됩니다.
href : 링크가 있는 주소
rel : 현재문서와 연결문서의 관계 표시
1. stylesheet : 스타일시트로연결
2. alternate : 문서의 대안 버전으로 연결
3. author : 저작자
4. help : 도움말
5. license : 문서의 저작권 정보
6. search : 검색도구
type : 연결 문서의 MIME유형 (href 속성이 설정될때만사용)
1. text/css : css
2. text/javascript : js
3. application/xml : xml



<script type="text/javascript">

자바스크립트를 실행하는 방법은 문서안에 <script> 태그를 이용해 작성하거나 외부의 스크립트 파일을 링크하는 것





      <form method="post" action="../pro/JoinPro.jsp" name="userInfo" onsubmit="return checkValue()">

* form


속성명

설명

method

폼을 전송할 방식. get 과 post 방식이 있음

name

하나의 웹 문서에서 여러개의 폼이 있을수 있으므로, 폼을 식별하기 위해 지정

action

폼을 전송할 서버의 스크립트 파일 지정

onsubmit

action속성을 활용하지 않고, onsubmit이벤트를 활용해서 스크립트로 처리가능

target

스크립트 파일을 현재의 창이 아닌 다른 위치에서 열리도록 지정

 

<form>은 폼 관련 태그들의 범위를 지정하고 포함하는 역할만을 수행한다. 속성을 통해 <form>이 동작하는 기능을 추가할 수 있습니다.


 action속성은 <form>태그에 입력된 내용을 처리하는 서버 프로그램의 url을 지정합니다. (처리할 프로그램의 경로를 지정)

 method속성은 get,post 인데, 두개중 사용자가 입력한 내용을 어떤 방식(get,post)으로 넘길 것인지 지정합니다.

-get : 주소 표시줄에 입력한 내용이 나타나며 256byte~4096byte까지의 데이터만을 서버로 전송할 수 있습니다.

  주소 표시줄에 입력내용이 노출되기 때문에 보안상의 문제가 민감한 경우에는 사용하지 않습니다.

-post : 입력된 내용의 크기에 제한을 받지 않고, 입력한 내용이 노출되지 않기 때문에 회원가입, 로그인 등에 많이 사용됩니다.





function checkValue()

        {
            if(!document.userInfo.id.value){
                alert("아이디를 입력하세요.");
                return false;
            }
            
            if(!document.userInfo.password.value){
                alert("비밀번호를 입력하세요.");
                return false;
            }
            
            // 비밀번호와 비밀번호 확인에 입력된 값이 동일한지 확인
            if(document.userInfo.password.value != document.userInfo.passwordcheck.value ){
                alert("비밀번호를 동일하게 입력하세요.");
                return false;
            }
        }





 if(!document.userInfo.id.value){  //만약 userinfo의 아이디값이 없다
                alert("아이디를 입력하세요.");     //경고창 alert
                return false;


if(!document.userInfo.password.value){ //만약 userinfo의 비번값이 없다
                alert("비밀번호를 입력하세요.");        //경고창 
                return false;


// 비밀번호와 비밀번호 확인에 입력된 값이 동일한지 확인
            if(document.userInfo.password.value != document.userInfo.passwordcheck.value ){
                alert("비밀번호를 동일하게 입력하세요.");
                return false;
            }







반응형
반응형




참조 : https://all-record.tistory.com/104?category=733042


JNDI

외부에 있는 객체를 가져오기 위한 기술


DBCP

데이터베이스와 연결된 커넥션을 만들어, 저장해두었다가 필요할 때 저장된 공간에서 가져다 쓰고 반환하는 기법






  • 1. API 관련 jar 파일 설치 - lib폴더 (ojdbc6.jar, tomcat-dbcp.jar)

  • 2. DBCP 정보 설정 - context.xml

  • 3. JNDI 리소스 사용 설정 - web.xml

  • 4. 자바 혹은 JSP 페이지에서 사용




  • 1. API 관련 jar 파일 설치 - lib폴더 (ojdbc6.jar, tomcat-dbcp.jar)

    (참조사이트에 들어가보면, 설치파일제공)



    2. DBCP 정보 설정 - context.xml

     [Servers] - [Tomcat v6.0 Server at localhost-config] 에 있는 context.xml 파일을 연다.

     아래와 같이 Resource 부분을 작성해준다.


    ip주소 : portnumber:dbname

    username

    password

    등부분은 자신에 맞게 수정해주어야한다.



    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
    <?xml version="1.0" encoding="UTF-8"?>
    <!--
      Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements.  See the NOTICE file distributed with
      this work for additional information regarding copyright ownership.
      The ASF licenses this file to You under the Apache License, Version 2.0
      (the "License"); you may not use this file except in compliance with
      the License.  You may obtain a copy of the License at
          http://www.apache.org/licenses/LICENSE-2.0
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
    --><!-- The contents of this file will be loaded for each web application --><Context>
     
        <!-- Default set of monitored resources. If one of these changes, the    -->
        <!-- web application will be reloaded.                                   -->
        <WatchedResource>WEB-INF/web.xml</WatchedResource>
        <WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
        <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
     
        <!-- Uncomment this to disable session persistence across Tomcat restarts -->
        <!--
        <Manager pathname="" />
        -->
        <Resource auth="Container" 
              name="jdbc/orcl" 
              driverClassName="oracle.jdbc.driver.OracleDriver" 
              type="javax.sql.DataSource" 
              url="jdbc:oracle:thin:@localhost:1521:orcl" 
              username="scott"
              password="1234" 
              loginTimeout="10" 
              maxActive="50" 
              maxIdle="20"
              maxWait="5000" 
              testOnBorrow="true" />
     
     
    </Context>
    cs


    3. JNDI 리소스 사용 설정 - web.xml



    web.xml을 생성한후, <resource-ref> 부분을 작성한다.


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
             xmlns="http://java.sun.com/xml/ns/javaee" 
             xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
             id="WebApp_ID" version="2.5">
     <display-name>JSP_create</display-name>
     
    <resource-ref>
         <description>connection</description>
         <res-ref-name>jdbc/orcl</res-ref-name>
         <res-type>javax.sql.DataSource</res-type>
         <res-auth>Container</res-auth>
    </resource-ref>
     
    </web-app>
     
    cs


    반응형

    + Recent posts