Jsp 회원가입 폼 css - jsp hoewongaib pom css

■ JoinForm.jsp

<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> 회원가입 화면 출처: //all-record.tistory.com/114 [세상의 모든 기록]

■ JoinPro.jsp

<%@ 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" %> 회원가입 처리 JSP <%-- JoinForm.jsp에서 입력한 정보를 넘겨 받아 처리한다. --%> <% // 한글 깨짐을 방지하기 위한 인코딩 처리 request.setCharacterEncoding("euc-kr"); %> <%-- 자바빈 관련 액션태그 사용 --%> <jsp:usebean id="memberBean"> <jsp:setproperty property="*" name="memberBean"> <% MemberDAO dao = MemberDAO.getInstance(); // 회원정보를 담고있는 memberBean을 dao의 insertMember() 메서드로 넘긴다. // insertMember()는 회원 정보를 JSP_MEMBER 테이블에 저장한다. dao.insertMember(memberBean); %> <div id="wrap"> <p> <b><SPAN color="gray" size="5">회원가입 정보를 확인하세요.</SPAN></b></p><p><SPAN color="blue"><%=memberBean.getName() %></SPAN>님 가입을 축하드립니다. </p><p> <%-- 자바빈에서 입력된 값을 추출한다. --%></p><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> </div> 출처: //all-record.tistory.com/114 [세상의 모든 기록] </jsp:setproperty></jsp:usebean></xmp></pre> <h3>■ join_style.css</h3> <pre><xmp> #wrap{ width:530px; margin-left:auto; margin-right:auto; text-align:center; } table{ margin-left:auto; margin-right:auto; border:3px solid skyblue } td{ border:1px solid skyblue } #title{ background-color:skyblue } 출처: //all-record.tistory.com/114 [세상의 모든 기록] </xmp></pre> <h3>■ DBConnection.java</h3> <pre><xmp> 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"); //envCtx의 lookup메서드를 이용해서 "jdbc/orcl"에 해당하는 객체를 찾아서 ds에 삽입 DataSource ds = (DataSource) envCtx.lookup("jdbc/orcl"); //getConnection메서드를 이용해서 커넥션 풀로 부터 커넥션 객체를 얻어내어 conn변수에 저장 Connection conn = ds.getConnection(); return conn; } } 출처: //all-record.tistory.com/114 [세상의 모든 기록] </xmp></pre> <h3>■ MemberDAO.java </h3> <pre><xmp> 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(); 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; try { // 커넥션을 가져온다. conn = DBConnection.getConnection(); // 자동 커밋을 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) { // 오류시 롤백 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() } 출처: //all-record.tistory.com/114 [세상의 모든 기록] </xmp></pre> <h3>■ MemberBean.java </h3> <pre><xmp> package jsp.member.model; import java.sql.Timestamp; // 데이터의 전달을 담당하는 클래스 - DTO 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;} } 출처: //all-record.tistory.com/110 [세상의 모든 기록] </xmp></pre> <h3>■ web.xml </h3> <pre><xmp> <web-app xmlns:xsi="//www.w3.org/2001/XMLSchema-instance" xmlns="//java.sun.com/xml/ns/javaee" xmlns:web="//java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemalocation="//java.sun.com/xml/ns/javaee //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> 출처: //all-record.tistory.com/114 [세상의 모든 기록] </xmp></pre> <pre><xmp> </xmp></pre> <pre><xmp> </xmp></pre></div></DIV></xmp></pre></div></div>

Toplist

최신 우편물

태그