board.QnaDTO

board.QnaDAO


1.새글입력 메서드명 : setContent()




글쓰기 : writeForm.jsp

답글쓰기 : rewriteForm.jsp

글리스트 : listView.jsp

뷰페이지 : contentView.jsp


table : qnaBoard

글번호 : num (primary key)

글제목 : title

글내용 : content

원본글 : ref(원본글이면 원본글의 num, 답변글이면,? 원본글의 num?)

답글순서 : step ( 최신글이면 1, ++ )

들여쓰기 : depth(원본글의 답변이면 1, 답변글의 답변글이면 2)



******************************************************************



Q&A 테이블


create table qnaboard(

num number(6) primary key,

title varchar2(2000),

content varchar2(3000),

ref number(6),

step numbeR(6),

depth number(6)


)



******************************************************************



QnaDTO.java


package board;


public class QnaDTO {

private int num;

private String title;

private String content;

private int ref;

private int step;

private int depth;

public int getNum() {

return num;

}

public void setNum(int num) {

this.num = num;

}

public String getTitle() {

return title;

}

public void setTitle(String title) {

this.title = title;

}

public String getContent() {

return content;

}

public void setContent(String content) {

this.content = content;

}

public int getRef() {

return ref;

}

public void setRef(int ref) {

this.ref = ref;

}

public int getStep() {

return step;

}

public void setStep(int step) {

this.step = step;

}

public int getDepth() {

return depth;

}

public void setDepth(int depth) {

this.depth = depth;

}

}




******************************************************************



package board;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import com.sun.corba.se.spi.orbutil.fsm.State;

public class QnaDAO {
private String user = "user02";
private String password = "user02";
private String url = "jdbc:oracle:thin:@192.168.116.128:1521:xe";
private String dirver = "oracle.jdbc.driver.OracleDriver";
private Connection con;
private PreparedStatement st;
private ResultSet rs;
public QnaDAO(){
try {
Class.forName(dirver);
con = DriverManager.getConnection(url, user, password);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/*
//setDummy 메소드 실행
public static void main(String[] args) {
QnaDAO q = new QnaDAO();
q.setDummy();
}
//Dummy data 만드는 메서드
public void setDummy(){
String sql = "insert into qnaboard values(?,?,?,?,0,0)";
try {
st = con.prepareStatement(sql);
for(int i=8 ; i<120 ; i++){
st.setInt(1, i);
st.setString(2, "title"+i);
st.setString(3, "content"+i);
st.setInt(4, i);
st.executeQuery();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
*/
//총 게시물 수를 받아오는 메서드
public int getCount(){
   int result = 0;
String sql = "select count(num) from qnaboard";
try {
st = con.prepareStatement(sql);
rs = st.executeQuery();
if(rs.next()){
result = rs.getInt(1);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
//리스트 받아오기
public ArrayList<QnaDTO> getList(int curpage){
int start = 0;
int last = 0;
start = (curpage-1)*10+1;
last = curpage*10;
String sql ="select * from"
+"(select rownum R, A.* from" 
+"(select * from qnaboard order by num desc) A)"
+ "where R between ? and ?";
ArrayList<QnaDTO> ar = new ArrayList<>();
try {
st = con.prepareStatement(sql);
st.setInt(1, 1);
st.setInt(2, 10);
rs = st.executeQuery();
while(rs.next()){
QnaDTO q = new QnaDTO();
q.setNum(rs.getInt("num"));
q.setTitle(rs.getString("title"));
q.setContent(rs.getString("content"));
q.setRef(rs.getInt("ref"));
q.setStep(rs.getInt("step"));
q.setDepth(rs.getInt("depth"));
ar.add(q);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ar;
}
//부모 새글 쓰기
public int setContent(QnaDTO qd){
int result = 0;
try {
int max = getMax()+1;
String sql = "insert into qnaboard values(?, ?, ?, ?, ?, ?)";
st = con.prepareStatement(sql);
st.setInt(1, max);
st.setString(2, qd.getTitle());
st.setString(3, qd.getContent());
st.setInt(4, max); //원본글의 ref는 자신의 num
st.setInt(5, 0); //원본글의 스텝 0
st.setInt(6, 0); //원보글의 들여쓰기 0
result = st.executeUpdate();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
//글의 최신번호를 가져오기위한 내부 메서드
private int getMax(){
int max = 0;
try {
String sql = "select max(num) from qnaboard";
Statement st = con.createStatement();
rs = st.executeQuery(sql);
if(rs.next()){
max = rs.getInt(1);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return max;
}
}



******************************************************************

index.jsp

<%@ 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>
<a href="writeForm.jsp">글쓰기</a>
<a href="listView.jsp?curpage=1">리스트보기</a>
</body>
</html>


******************************************************************


writeForm.jsp


<%@ 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>

원본글쓰기 폼

<form action="writePro.jsp" method="post">


<input type="text" name="title"><br>

<textarea rows="20" cols="20" name="content"></textarea><br>

<input type="submit" value="등록">


</form>


</body>

</html>



******************************************************************


writePro.jsp


<%@page import="board.QnaDAO"%>

<%@ 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>

<jsp:useBean id="qd" class="board.QnaDTO" />

<jsp:setProperty property="*" name="qd"/>

<%

QnaDAO qa = new QnaDAO();

int result = qa.setContent(qd);

if(result>0){

%>

<h2>글쓰기 성공</h2>

<a href="#">리스트 보기</a>

<% }else{ %>

<h2>글쓰기 실패</h2>

<a href="./qnaWrite.jsp">글쓰기</a>

<% }  %>



</body>

</html>


******************************************************************


listView.jsp



<%@page import="board.QnaDTO"%>

<%@page import="java.util.ArrayList"%>

<%@page import="board.QnaDAO"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<%

int curpage = Integer.parseInt(request.getParameter("curpage"));

QnaDAO qdao = new QnaDAO();

ArrayList<QnaDTO> ar = qdao.getList(curpage);

int total = qdao.getCount();

if(total%10==0){

total = total/10;

}else{

total = (total/10)+1;

}

%>    

<!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>

<table>

<tr>

<td>번호</td><td>제목</td>

</tr>

<%

for(int i=0 ; i <ar.size() ; i++){

%>

<tr>

<td><%=ar.get(i).getNum() %></td>

<td><%=ar.get(i).getTitle() %></td>

</tr>

<%} %>

<%

for(int i=1 ; i<=total ; i++){%>

<a href="listView.jsp?curpage=<%=i %>"><%=i %></a>

<% }%>

</table>

</body>

</html>




******************************************************************

답글 들여쓰기 쿼리문





insert into qnaboard values(1,'test','test',1,0,0)

insert into qnaboard values(2,'test2','test2',2,0,0)


insert into qnaboard values(3,'retest' ,'retest',1,1,1)


insert into qnaboard values(4,'re2test','re2test',1,1,1)


insert into qnaboard values(5,'re3test','re3test',1,1,1)



update qnaboard set step=step+1 where ref=1 and step>0;


select * from qnaboard


select * from qnaboard order by ref desc;


select * from qnaboard order by step asc;



select * from qnaboard order by ref desc, step asc







******************************************************************


parameter 받아오는 방법

1. get방식

2. useBean 액션태그 사용


******************************************************************


자바 전체 주석 한번에

씨프트 + 화살표로 블럭지정  + 컨트롤 + 슬러시







블로그 이미지

테시리

,
게시판실습




블로그 이미지

테시리

,

dothome : mySQL 지원


mvc2 공부


영어 공부


*********************************************************

<답글>


글번호     작성자     제목     내용      re글번호     들여쓰기                     순서

1           ad          ad       ad        1             0                             0

2           ad2        ad2      ad2       2             0                            0

3           re          re         re        1             0(1번글들여쓰기)+1=1     +1

4           re2         re2       re2        2            1                       

5           re3         re3       re3        3            1(3번글들여쓰기)+1=2

7           re4         re4       re4       1             1번들여쓰기+1          3번글순서+1


답글 ==> 들여쓰기



교재 p.128 제10강 게시판 만들기


필드명

ref : 원본글

step : 답변글 순서

depth : 들여쓰기


교재 p.133 writeForm 글쓰기폼


******************************************************************



글번호   작성자   제목   내용   ref    depth     step

1         ad       ad      ad     1       0         0

2         re       re        re     1       1         1



답변글

num=?

int ref = 누구의 글 1

int step = 답변글 순서 0

int depth = 들여쓰기 0

number : 2


where ref=1 and step>0


step = 1

depth = depth +1



num = ?


number = 3


글번호   작성자   제목   내용   ref    depth     step

1         ad       ad      ad     1       0         0

2         re       re        re     1       1        step=step+1=2

3         res     res       res     1      1         1



******************************************************************



글번호   작성자   제목   내용   ref    depth     step

1          ad      ad     ad     1       0         0

2          ads    sfd     ad     1        1        1



신규글 ==>  글번호 = ref  새글은 글번호와 ref가 일치



1. 글번호? =  max(no)+1




















블로그 이미지

테시리

,

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

<script type="text/javascript">

function check() {

var d = document.myForm.id;

alert(d.value);

}


function  idCheck() {

var yId = document.myForm.id;

// location.href="./result1.html?id="+yId.value;

window.open("./result1.html?id="+yId, "check", "width=500px height=300px") ;

}

</script>

</head>

<body>


<form action="result1.html" method="post" name="myForm">

<input type="text" name="id" id="d1"><button onclick="idCheck()">중복확인</button>

<input type="password" name="pw">

<input type="submit" onclick="=return check()">

</form>

</body>

</html>



********************************************************************


개인프로젝트 작업



-멤버DB

-테이블명 : recipemember

-필드명

- id

- pw

- name

- phone

- gender

- job

- age




********************************************************************


pool설정

11버젼부터 ojdbc6

서버 과부하를 막기위해 권장?




context.xml


<?xml version="1.0" encoding="UTF-8"?>

<Context>

    <Resource name="jdbc/myOracle" 

    auth="Container"

   driverClassName="oracle.jdbc.driver.OracleDriver"

   type="javax.sql.DataSource"

           username="user01" 

   password="user01" 

             url="jdbc:oracle:thin:@192.168.116.128:1521:xe"

          maxActive="500"  

  maxIdle="100"      

   maxWait="-1"/>    

</Context>



web.xml


<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">

<resource-ref>

      <description>ConnectionPool</description>

      <res-ref-name>jdbc/myOracle</res-ref-name>

      <res-type>javax.sql.DataSource</res-type>

      <res-auth>Container</res-auth>

  </resource-ref>

</web-app>




test.jsp



<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<%@ page import="javax.naming.*" %>

<%@ page import="javax.sql.*" %>

<%@ page import="java.sql.*" %>

<!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>

<%

Context initCtx = new InitialContext();

Context envCtx = ( Context ) initCtx.lookup( "java:comp/env" );

DataSource ds = ( DataSource ) envCtx.lookup( "jdbc/myOracle" );

Connection con = ds.getConnection();


String sql = "select * from member";

PreparedStatement st = con.prepareStatement(sql);

ResultSet rs = st.executeQuery();

if(rs.next()){

%>

<%= rs.getInt("age") %>

<%= rs.getString("id") %>

<% } %>

</body>

</html>





********************************************************************





블로그 이미지

테시리

,
구글 캠퍼스 스타트업 리쿠르팅 데이 참가




블로그 이미지

테시리

,

공지사항

글쓰기 

글쓰기 처리

리스트

컨텐트

수정

삭제



프로젝트 폴더구성, 파일구성, DB테이블 구성



*****************************************************


게시글 DB 테이블 필드명


==> 번호, 작성자, 타이틀, 내용, TIMESTAMP


JSP 교재 참고하기



create table test(

today timestamp

);




블로그 이미지

테시리

,

팀프로젝트에 앞서서 개별프로젝트 먼저 진행



뭐 만들지?


고민


*********************************************************


게시판 밑에 페이지 블록 묶음과 이전, 다음 링크 만들기


BoardDAO.java


package myDB;


import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.ArrayList;

import java.util.List;


public class BoardDAO {

private String user = "user01";

private String password = "user01";

private String url = "jdbc:oracle:thin:@192.168.116.128:1521:xe";

private String driver = "oracle.jdbc.driver.OracleDriver";

private Connection con;

private PreparedStatement st;

private ResultSet rs;

public BoardDAO(){

try {

Class.forName(driver);

con = DriverManager.getConnection(url, user, password);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

public List<BoardDTO> getlist(int curpage){

int start = 0;

int last = 0;

start = curpage*10-9;

last = curpage*10;

String sql="select * from (select rownum R, A.* from"

+"(select * from noticboard order by no desc) A)"

          +"where R between ? and ?";

List<BoardDTO> ar = new ArrayList<>();

try {

st = con.prepareStatement(sql);

st.setInt(1, start);

st.setInt(2, last);

   rs = st.executeQuery();

   while(rs.next()){

    BoardDTO b = new BoardDTO();

    b.setNo(rs.getInt("no"));

    b.setTitle(rs.getString("title"));

    b.setWriter(rs.getString("writer"));

    b.setContents(rs.getString("contents"));

    ar.add(b);

   }

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return ar;

}

//총 게시글 수 리턴메소드 ==> 첫페이지, 마지막페이지 리턴으로 변경

public int getCount(int curpage){

int firstPage = 0; //처음 들어갈 번호

int lastPage = 0; //마지막 들어갈 번호

int block = 1 ; //블럭 그룹번호

int pagePerBlock = 5 ;  //한 블럭에 들어갈 페이지 번호 수

int count  = 0;

//받아온 curpage를 가지고 어느 block에 속하는지를 구하는 조건문

if(curpage%pagePerBlock==0){

block = curpage/pagePerBlock ;

}else{

block = curpage/pagePerBlock + 1 ;

}

//block을 이용해서 firstpage, lastpage를 구하는 공식

//firstPage = (block-1)*pagePerBlock+1;

//lastPage = block*pagePerBlock ;

/*

String sql = "select count(no) from noticboard";

try {

st = con.prepareStatement(sql);

rs = st.executeQuery();

if(rs.next()){

count = rs.getInt(1);

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

int t = count%10;

count = count/10;

if(t!=0){

count = count +1;

}

return count;

*/

return block;

}

public int getC(){

int totalContent = 0; //전체 글 수

int totalPage = 0; //전체 페이지 수 

int totalBlock = 0;

//전체 글 수를 받아 오는 query문

String sql = "select count(no) from noticboard";

try {

st = con.prepareStatement(sql);

rs = st.executeQuery();

if(rs.next()){

totalContent = rs.getInt(1);

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

// 전체 글 수를 이용해서 전체 페이지 수를 구하는 공식

if(totalContent%10==0){

totalPage = totalContent/10 ;

}else{

totalPage = (totalContent/10) +1;

}

// totalPage를 이용해서 전체 block 수를 구하는 공식

if(totalPage%5==0){

totalBlock = totalPage/5;

}else{

totalBlock = (totalPage/5)+1;

}

return totalBlock;

}

}





listView.jsp

<%@page import="myDB.BoardDTO"%>
<%@page import="java.util.List"%>
<%@page import="myDB.BoardDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<%
int curpage = Integer.parseInt(request.getParameter("curpage"));
BoardDAO d = new BoardDAO();
List<BoardDTO> ar = d.getlist(curpage);
int block = d.getCount(curpage);
int totalBlock = d.getC();
%>    
<!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>공지사항페이지</title>
<link type="text/css" href="./practice.css" rel="stylesheet">
<style type="text/css">
table{
border:  1px solid blue;
border-collapse: collapse;
border-spacing: 0px;
width: 500px;
margin : 0 auto;
}
div{
width: 500px;
margin : 0 auto;
}
h3{
width : 500px;
margin : 0 auto;
}
</style>
</head>
<body>
<h3>
<a href="index.jsp">메인으로</a><br>
공지사항입니다</h3><br>
<table>
<tr>
<td>번호</td><td>제목</td><td>작성자</td>
</tr>
<%
for(int i=0;i<ar.size();i++){
%>
<tr>
<td><%=ar.get(i).getNo() %></td>
<td><%=ar.get(i).getTitle() %></td>
<td><%=ar.get(i).getWriter() %></td>
</tr>
<%} %>
</table>
<p></p>
<div>
 
<%
   int start = (block-1)*5+1;
int last = block*5;
if(block > 1){%>
<a href="listView.jsp?curpage=<%=start-1%>">[이전]</a>
<%}
for(int i=start ; i<= last ; i++){
%>
<a href="listView.jsp?curpage=<%=i %>"><%=i %></a>
<%}
if(block < totalBlock){
%>
<a href="listView.jsp?curpage=<%=last+1 %>">[다음]</a>
<% }%>
</div>



</body>
</html>



*********************************************************


어제 작업한 부분에서

로그인한 회원정보 보는 페이지

1. 처음에는 DAO에 정보보는 메소드를 만들어서 불러왔으나 최근에 가입한 회원정보를 불러옴 (쿼리문 수정해야할 것으로 보임)

2. 해결책 , 차라리 세션으로 객체를 생성해서 한번에 불러오니 해결




*********************************************************


private String user = "DB아이디";
private String password = "DB암호";
private String url="jdbc:oracle:thin:@서버아이피:서버SID";
private String driver="oracle.jdbc.driver.OracleDriver";
private Connection con;
private PreparedStatement st;
private ResultSet rs;  // select 문은 리턴타입이 리절트셋


*********************************************************


게시판 연습

index2.jsp

<%@ 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>
<a href="viewList.jsp?curpage=1">공지사항보기</a>
</body>
</html>


viewList.jsp

<%@page import="notice_board.NoticeDTO"%>
<%@page import="java.util.List"%>
<%@page import="notice_board.NoticeDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
int curPage = Integer.parseInt(request.getParameter("curpage") );
NoticeDAO nd = new NoticeDAO();
    List<NoticeDTO> ar =  nd.getList(curPage);
int block = nd.getBlock(curPage);
int start = block*5 -4;
int last = block*5;
int [] numAr = nd.getTotalBlock();
//int count = nd.getCount();
%>
<!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>
<style type="text/css">
table {
width: 800px;
border: 1px solid blue;
border-spacing: 0px;
border-collapse: collapse;
margin: 0 auto;
}
td {
border: 1px dashed blue;
text-align: center;
}
div {
width: 800px;
margin: 0 auto;
}
</style>
</head>
<body>
<table>
<tr>
<td>글번호</td><td>글제목</td><td>작성자</td>
</tr>
<%
for(int i=0;i<ar.size();i++){
%>
<tr>
<td><%=ar.get(i).getNo() %></td>
<td><%=ar.get(i).getTitle() %></td>
<td><%=ar.get(i).getWriter() %></td>
</tr>
<%} %>
</table>
<div>
<% if(block>1){ %>
<a href="viewList.jsp?curpage=<%= start-1%>">[이전]</a>
<%} %>
<%
if(block>=numAr[1]){
last = numAr[0];
}
for(int i=start; i<=last;i++){ %>
<a href="viewList.jsp?curpage=<%=i %>"><%=i%></a>
<%}
if(block < numAr[1]){%>
<a href="viewList.jsp?curpage=<%=last+1 %>">[다음]</a>
<%}%>
</div>
</body>
</html>


NoticeDTO.java

package notice_board;

public class NoticeDTO {
private int no;
private String writer;
private String title;
private String content;
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public String getWriter() {
return writer;
}
public void setWriter(String writer) {
this.writer = writer;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContents() {
return content;
}
public void setContents(String content) {
this.content = content;
}
}



NoticeDAO.java

package notice_board;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class NoticeDAO {
private String user = "user01";
private String password = "user01";
private String url="jdbc:oracle:thin:@192.168.116.128:1521:xe";
private String driver="oracle.jdbc.driver.OracleDriver";
private Connection con;
private PreparedStatement st;
private ResultSet rs;
public NoticeDAO(){
try {
Class.forName(driver);
con = DriverManager.getConnection(url, user, password);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//******************************************************//
//DB에서 리스트를 꺼내오는 메소드
public List<NoticeDTO> getList(int curPage){
List<NoticeDTO> ar = new ArrayList<>();
//curPage =1 , 2
int start = 0 ; // setInt 1번에 들어갈 번호 , 1 , 11 ...
int last = 0; // setInt 2번에 들어갈 번호 , 10 , 20 ...
//start = curPage*10-9;
start = (curPage*10)-9;
last = curPage * 10;
String sql ="select * from"
+"(select rownum R, A.* from" 
+"(select * from noticboard order by no desc) A)"
+"where R between ? and ?";
try {
st = con.prepareStatement(sql);
st.setInt(1, start);
st.setInt(2, last);
rs = st.executeQuery();
while(rs.next()){
NoticeDTO n = new NoticeDTO();
n.setNo(rs.getInt("no"));
n.setTitle(rs.getString("title"));
n.setWriter(rs.getString("writer"));
n.setContents(rs.getString("contents"));
ar.add(n);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ar;
}
public int[] getTotalBlock(){
int [] numAr = new int [2];
int pages=0;// 총페이지 수를 담을 변수
String sql = "select count(no) from noticboard";
try {
st = con.prepareStatement(sql);
rs = st.executeQuery();
if(rs.next()){
pages = rs.getInt(1);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(pages%10 ==0){
pages = pages/10;
}else {
pages = pages/10+1;
}
int totalBlock=0;//총 블럭수를 담을 변수
if(pages%5==0){
totalBlock= pages/5;
}else {
totalBlock= pages/5+1;
}
numAr[0]=pages;
numAr[1]=totalBlock;
return numAr;
}
//******************************************************//
//페이지당 블럭을 알아오는 메서드
//block 번호를 가지고 페이지 번호를 알아내려함
//block 이 1이라면 페이지 번호는 1~5까지 출력
//block 이 2 이라면 페이지 번호는 6~10까지 출력
public int getBlock(int curPage){
int block=0; //블럭의 번호를 저장하는 변수
int pagePerBlock=5; //블럭당 페이지 수
if(curPage%pagePerBlock==0){
block = curPage/pagePerBlock;
}else{
block = curPage/pagePerBlock+1;
}
return block;
}
}




*********************************************************

다음주까지 개인프로젝트 끝


같은 주제를


다른 사람들이 다른 방식으로 표현


주제 : 백주부가 지금까지 발표한 레시피를 소개하는 페이지


요구사항


1.회원제 : 회원가입 후 로그인

2.공지사항 : 관리자

3.방명록 : 회원만

4.Q&A게시판 : 회원만

5.게시판 리스트 보기 : 비회원도 가능, 그러나 상세보기는 회원만 가능


방명록,Q&A게시판을 사용하기 위해서는 회원가입, 로그인



[회원정보]

-이름

-아이디

-비밀번호

-전화번호

-성별

-직업

-나이



요구사항

검색기능 - 게시판(option)

관리자모드 - 회원검색기능(수정,삭제)(option)

관리자는 모든 게시판을 수정 삭제 가능(option)

회원은 각자의 정보를 수정할 수 있는 페이지가 있어야함.



테이블


회원테이블

공지사항테이블

방명록테이블

Q&A테이블


DB에 총 4개의 테이블 구성



PPT로 계획서 만들어서 제출



폴더, 패키지 나누기



*******************************************************

카페24 - DB호스팅 - MySQL 










블로그 이미지

테시리

,

JSP 교재


p.128 제10강 게시판만들기

p.139 글목록 가져오기




SELECT * FROM (

 SELECT ROWNUM R, A.* FROM (select nun, title, wdate

FROM board order by ?? desc) A




위에거 해석 

1. ROWNUM R : 가상의 rownum(행의수?) 변수를 R이라고 지정한다.

2. (select nun, title, wdate FROM board order by ?? desc) A  : board테이블에서 내림차순으로 nun, title, wdate를 뽑아 가상의 테이블 A로 지정

3. A.* : 가상의 테이블 A의 모든 필드를 불러온다.






최신글 3개 가져오기

select * from 

(select rownum R, A.* from

(select * from noticboard order by no desc) A)

where R between 1 and 3



>

1. (select * from NOTICBOARD order by no desc) A) : 가상의 테이블 A만듦.

2. ROWNUM R : 가상의 변수 rownum (행의수)을 R로 지정

3. A.* : A에서 모든 것을 가져온다. 




서브쿼리 ! : 쿼리안에 또다른 select 문이 등장



데이터베이스 교재

p.48 제 7강 서브쿼리




select count(no), max(no) from noticboard

select rownum R, writer from noticboard


이거 스크랩북에 다시 쳐보기



오늘쓴 스크랩북



select * from NOTICBOARD 


select * from 

(select ROWNUM R, A.* from 

(select * from NOTICBOARD order by no desc) A)

where R between 1 and 3


select * form 

(select * from noticboard order by no desc)

order by title desc


select * from 

(select rownum R, A.* from

(select * from noticboard order by no desc) A)

where R between 1 and 3


select count(no), max(no) from noticboard

select rownum R, writer from noticboard





*****************************************************************************8




DB연결 DAO클래스

DbDAO.java


package jsp_0914;


import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import java.util.ArrayList;

import java.util.List;


import com.sun.corba.se.pept.transport.Connection;


public class DbDAO {

private String user = "user01";

private String password = "user01";

private String url="jdbc:oracle:thin:@192.168.116.128:1521:xe";

private String driver="oracle.jdbc.driver.OracleDriver";

private java.sql.Connection con;

private PreparedStatement st;

private ResultSet rs;

 

public DbDAO(){

try {

Class.forName(driver);

con = DriverManager.getConnection(url, user, password);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

public List<BoardDTO> getlist(int curpage){

//String sql = "select * from noticboard order by no desc";

int start=0;

int last=0;

start = curpage*10-9;

last = curpage*10;

String sql = "select * from "

+ "(select rownum R, A.* from "

+ "(select * from noticboard order by no desc) A) "

+ "where R between ? and ?";

List<BoardDTO> ar = new ArrayList<>();

try {

st = con.prepareStatement(sql);

st.setInt(1, start);

st.setInt(2, last);

rs = st.executeQuery();

while(rs.next()){

BoardDTO b = new BoardDTO();

b.setNo(rs.getInt("no"));

b.setTitle(rs.getString("title"));

b.setWriter(rs.getString("writer"));

b.setContents(rs.getString("contents"));

   ar.add(b);

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return ar;

}

 

//총 게시물의 수를 리턴하는 메소드

public int getCount(){

int count = 0;

String sql = "select count(no) from noticboard";

try {

st = con.prepareStatement(sql);

rs = st.executeQuery();

if(rs.next()){

count = rs.getInt(1);

}

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

int t = count%10;

count = count/10;

if(t!=0){

count=count+1;

}

return count;

}

/*

//임의의 글 30개 작성메소드

public void setDb(){

try {

Statement st = con.createStatement();

int num = 11;

for(num=11 ; num<41 ; num++ ){

String sql = "insert into noticboard values";

sql=sql+"("+num+", '"+num+"', '"+num+"', '"+num+"')";

st.executeQuery(sql);

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

public static void main(String[] args) {

DbDAO d = new DbDAO();

d.setDb();

}


*/

}





게시판DTO클래스
BoardDTO.java

package jsp_0914;

public class BoardDTO {
private int no;
private String writer;
private String title;
private String contents;
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public String getWriter() {
return writer;
}
public void setWriter(String writer) {
this.writer = writer;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContents() {
return contents;
}
public void setContents(String contents) {
this.contents = contents;
}
}



리스트보기
listView.jsp

<%@page import="com.sun.org.apache.bcel.internal.generic.CPInstruction"%>
<%@page import="java.util.List"%>

<%@page import="jsp_0914.BoardDTO"%>

<%@page import="jsp_0914.DbDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<%

int curpage =  Integer.parseInt( request.getParameter("curpage") );
DbDAO d = new DbDAO();
List<BoardDTO> ar = d.getlist(curpage);
int count = d.getCount();
%>
<!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>
<style type="text/css">
table{
border : 1px solid red;
border-collapse: collapse;
border-spacing: 0px;
width : 500px;
margin : 0 auto;
}
div{
width:  500px;
margin : 0px auto;
}
</style>
</head>
<body>
<table>
<tr>
<td>번호</td><td>제목</td><td>작성자</td>
</tr>
<%
for(int i=0;i<ar.size();i++){
%>
<tr>
<td><%=ar.get(i).getNo() %></td>
<td><%=ar.get(i).getTitle() %></td>
<td><%=ar.get(i).getWriter() %></td>
</tr>
<%} %>
</table>

<p></p>
<div>
<%
for(int i=1 ; i<=count ; i++ ){
%>
<a href="listView.jsp?curpage=<%=i %>"><%=i %></a>
 <%} %>
</div>


</body>
</html>



인덱스

index.jsp



<%@ 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>

<a href="listView.jsp?curpage=1">리스트</a>

</body>

</html>











********************************************************************


notice_list.txt



** 게시물 리스트를 그룹화 **


1. DB에서 모든 게시물을 get


 1) 조건 : 내림차순으로 정렬

    sql = select * from noticboard order by no desc


 2) 조건 : 한 페이지에 보일 리스트의 갯수만 get

   select * from

   (select rownum R, A.* from 

   (select * from noticboard order by no desc) A )

   where r > ? and r < ?


    select * from

   (select rownum R, A.* from 

   (select * from noticboard order by no desc) A )

   where between ? and ?



   r > ? and r < ?  == 이 부분  : between ? and ? 과 같은 의미



   

2. rownum 구하기

  1) jsp 페이지에서 페이지 번호를 매개변수를 통해서 get (curpage);

  2) start = curpage*10-9

  3) last = curpage*10



3. jsp 페이지에 curpage 번호를 자동으로 프린트

 1) DB에서 총 게시물의 갯수를 get (count);

 2) int t = count%10;

 3) count = count/10;

 4) if(t != 0 ){ count++ }



4. 페이지블록 만들기 (번호10개씩 끊기, 내일 )





********************************************************************










































블로그 이미지

테시리

,

주의사항


회원가입 form에서 


각 인풋의 name 명과 DTO 클래스의 변수명은 무조건 일치시켜야 한다. ( jsp: usebean으로 연결되니까)


그리고


DB의 필드명과 DTO 변수명은 일치시키는 것이 알아보기 편하다.




***************************************************************************




로그인



일반회원 로그인

000님 환영합니다

공지사항보기 회원정보수정 회원탈퇴 로그아웃

공지사항보기->리스트->글쓰기x

컨탠츠뷰 -> 수정x,삭제x,목록O



admin 로그인

000님 환영합니다

공지사항보기 회원정보수정 전체회원보기 회원탈퇴 로그아웃

공지사항보기->리스트->글쓰기O

컨탠츠뷰 -> 수정O,삭제O,목록O




writer는 admin으로 고정, 수정x


블로그 이미지

테시리

,

회원가입, 탈퇴


Java 파일


member패키지


MemberDAO.java


package member;


import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;


public class MemberDAO {

private String user = "user01";

private String password = "user01";

private String url="jdbc:oracle:thin:@192.168.116.128:1521:xe";

private String driver="oracle.jdbc.driver.OracleDriver";

private Connection con;

private PreparedStatement st;

private ResultSet rs;

//회원 탈퇴 메서드

public int getDel(MemberDTO m){

int result=0;

try {

Class.forName(driver);

con = DriverManager.getConnection(url, user, password);

String sql = "delete saram where id=?";

st = con.prepareStatement(sql);

st.setString(1, m.getId());

result= st.executeUpdate();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

disconnect(st, con);

return result;

}

//회원가입 메서드

public int getJoin(MemberDTO m){

int result=0;

try {

Class.forName(driver);

con = DriverManager.getConnection(url, user, password);

String sql = "insert into saram(id, pw, name, age, gender, salary) values(?, ?, ?, ?, ?, ?)";

st = con.prepareStatement(sql);

st.setString(1, m.getId());

st.setString(2, m.getPw());

st.setString(3, m.getName());

st.setInt(4, m.getAge());

st.setString(5, m.getGender());

st.setInt(6, m.getSalary());

result = st.executeUpdate();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return result;

}

//getlogin 로그인 판별 메서드

public MemberDTO getLogin(MemberDTO m){

//MemberDTO md = null;

try {

Class.forName(driver);

con = DriverManager.getConnection(url, user, password);

String sql = "select * from saram where id=? and pw=?";

st = con.prepareStatement(sql);

st.setString(1, m.getId());

st.setString(2, m.getPw());

rs = st.executeQuery();

if(rs.next()){

//md = new MemberDTO();

m.setId(rs.getString("id"));

m.setPw(rs.getString("pw"));

m.setName(rs.getString("name"));

m.setAge(rs.getInt("age"));

m.setGender(rs.getString("gener"));

m.setSalary(rs.getInt("salary"));

}else {

m = null;

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

disconnect(rs, st, con);

return m;

}

private void disconnect(PreparedStatement st, Connection con){

try {

st.close();

con.close();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

private void disconnect(ResultSet rs, PreparedStatement st, Connection con){

try {

rs.close();

st.close();

con.close();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}


}





MemberDTO.java



package member;


import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;


public class MemberDAO {

private String user = "user01";

private String password = "user01";

private String url="jdbc:oracle:thin:@192.168.116.128:1521:xe";

private String driver="oracle.jdbc.driver.OracleDriver";

private Connection con;

private PreparedStatement st;

private ResultSet rs;

//회원 탈퇴 메서드

public int getDel(MemberDTO m){

int result=0;

try {

Class.forName(driver);

con = DriverManager.getConnection(url, user, password);

String sql = "delete saram where id=?";

st = con.prepareStatement(sql);

st.setString(1, m.getId());

result= st.executeUpdate();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

disconnect(st, con);

return result;

}

//회원가입 메서드

public int getJoin(MemberDTO m){

int result=0;

try {

Class.forName(driver);

con = DriverManager.getConnection(url, user, password);

String sql = "insert into saram(id, pw, name, age, gender, salary) values(?, ?, ?, ?, ?, ?)";

st = con.prepareStatement(sql);

st.setString(1, m.getId());

st.setString(2, m.getPw());

st.setString(3, m.getName());

st.setInt(4, m.getAge());

st.setString(5, m.getGender());

st.setInt(6, m.getSalary());

result = st.executeUpdate();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return result;

}

//getlogin 로그인 판별 메서드

public MemberDTO getLogin(MemberDTO m){

//MemberDTO md = null;

try {

Class.forName(driver);

con = DriverManager.getConnection(url, user, password);

String sql = "select * from saram where id=? and pw=?";

st = con.prepareStatement(sql);

st.setString(1, m.getId());

st.setString(2, m.getPw());

rs = st.executeQuery();

if(rs.next()){

//md = new MemberDTO();

m.setId(rs.getString("id"));

m.setPw(rs.getString("pw"));

m.setName(rs.getString("name"));

m.setAge(rs.getInt("age"));

m.setGender(rs.getString("gener"));

m.setSalary(rs.getInt("salary"));

}else {

m = null;

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

disconnect(rs, st, con);

return m;

}

private void disconnect(PreparedStatement st, Connection con){

try {

st.close();

con.close();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

private void disconnect(ResultSet rs, PreparedStatement st, Connection con){

try {

rs.close();

st.close();

con.close();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}


}




index.jsp 인덱스파일


<%@ 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>
<a href="./join/joinForm.jsp">회원가입</a> <br>
<a href="./login/loginForm.jsp">로그인</a>


</body>
</html>



회원가입 joinForm.jsp

<%@ 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>
<form action="./joinPro.jsp" method="post">
ID : <input type="text" name="id"><br>
pw : <input type="password" name="pw"><br>
name : <input type="text" name="name"><br>
age : <input type="text" name="age"><br>
gender : man<input type="radio" name="gender" value="man">
woman<input type="radio" name="gender" value="woman"><br>
salary : <input type="text" name="salary"><br>
<input type="submit">
</form>

</body>
</html>


회원가입process   joinPro.jsp

<%@page import="member.MemberDAO"%>
<%@ 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 m = new MemberDTO(); -->
<jsp:useBean id="m" class="member.MemberDTO" />
<jsp:setProperty property="*" name="m"/>
<%
MemberDAO md = new MemberDAO();
int check = md.getJoin(m);
String message =null;
if(check > 0){
message = "회원가입이 완료 되셨습니다.";
}else {
message = "회원 가입에 실패 하셨습니다.";
}
request.setAttribute("result", message);
%>
<jsp:forward page="./joinResult.jsp" />



</body>
</html>



회원가입 결과  joinResult.jsp


<%@ 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>
<%
String result = (String)request.getAttribute("result");
%>
<%= result %>
<a href="../index.jsp">홈으로</a>

</body>
</html>




로그인 폼 loginForm.jsp


<%@ 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>

<form action="./loginPro.jsp" method="post">

ID : <input type="text" name="id">

pw : <input type="password" name="pw">

<input type="submit" value="로그인">

</form>


</body>

</html>



로그인 프로세스  loginPro.jsp


<%@page import="member.MemberDTO"%>

<%@page import="member.MemberDAO"%>

<%@ 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>

<jsp:useBean id="mm" class="member.MemberDTO" />

<jsp:setProperty property="*" name="mm"/>

<%

//String id = request.getParameter("id");

//String pw = request.getParameter("pw");

MemberDAO m = new MemberDAO();

MemberDTO mmd = m.getLogin(mm);

if(mmd != null){

session.setAttribute("mem", mmd);

}else {

String message = "로그인 실패";

request.setAttribute("result", message);

}

%>


<jsp:forward page="loginResult.jsp" />



</body>

</html>




로그인결과 loginResult.jsp




<%@page import="member.MemberDTO"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<%

MemberDTO m = (MemberDTO)session.getAttribute("mem"); 

%>

<!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>

<%if(m != null){%>

<p><%= m.getName() %> 님 환영합니다.</p>

<a href="modPro.jsp">회원정보 수정</a>

<a href="logoutPro.jsp">로그아웃</a>

<a href="deletePro.jsp">회원탈퇴</a>


<%}else {

String result = (String)request.getAttribute("result");

%>

<%= result %>

<a href="../index.jsp">Home</a>

<% } %>



</body>

</html>



로그아웃  logoutPro.jsp


<%@ 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>

<%

session.invalidate();

response.sendRedirect("../index.jsp");

%>

</body>

</html>



회원탈퇴 deletePro.jsp


<%@page import="member.MemberDAO"%>

<%@page import="member.MemberDTO"%>

<%@page import="java.sql.PreparedStatement"%>

<%@page import="java.sql.DriverManager"%>

<%@page import="java.sql.Connection"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<%

MemberDTO m = (MemberDTO)session.getAttribute("mem");

MemberDAO md = new MemberDAO();

int result = md.getDel(m);

String message=null;

if(result>0){

message ="그동안 이용해 주셔서 개뿔";

session.invalidate();

}else {

message ="들어올때는 맘대로 나갈때는 맘처럼 안되지..ㅋㅋ";

}

request.setAttribute("result", message);

%>

<!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>

<jsp:forward page="deleteResult.jsp" />


</body>

</html>



회원탈퇴 결과 deleteResult.jsp


<%@ 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>

<%

String message = (String)request.getAttribute("result");

%>

<%= message %>

<a href="../index.jsp">Home</a>


</body>

</html>




*******************************************************************************


싱글톤 : 객체 하나만 만들어서 사용하는 것 



*******************************************************************************

다음 시간 게시판 만들기   ===> arraylist 개념 공부해오기







블로그 이미지

테시리

,