JSP에서 이전글 제목.다음글 제목 생성하기 오류

JSP에서 이전글 제목.다음글 제목 생성하기 오류

작성일 2008.03.29댓글 2건
    게시물 수정 , 삭제는 로그인 필요

 

고수님들 한수좀 해결해주세요/정말 환장합니다/

지금 수십번 올려건만 말로만 알려주니 머가먼지 모르겠습니다/

어떻게 하는지 소스를 수정해주세요?

그럼 그림과 소스 올립니다/

 


글내용 보기하단에 다음글 제목과 이전글 나오게 해결 하여주세요/

BoardMgr.java

package ch12;

import java.sql.*;
import java.text.*;
import java.util.*;
import java.util.Date;

public class BoardMgr {

private DBConnectionMgr pool = null;//객체를 선언

public BoardMgr() {
try{
pool = DBConnectionMgr.getInstance();//메소드로 객체를 생성
}catch(Exception e){
System.out.println("Error : 커넥션 가져오기 실패!!");
}
}
//
public Vector getBoardList(String keyField, String keyWord) {
Connection con = null;          //데이타베이스와 연결 선언
Statement stmt = null;          //Statement객체선언
ResultSet rs = null;            //ResultSet객체선언
String strQuery = null;         //String형SQL문 서언
Vector boardList = new Vector();//Vector객체생성

try {
con = pool.getConnection();//DBConnectionMgr pool객체를 통해DB연결sql문을dbqhsorldnkgksStatement객체생성
stmt = con.createStatement();
if(keyWord.equals("null") || keyWord.equals("")){
strQuery = "select * from board order by pos asc";//모든계시물가져오기위한 SQl문
}else{
strQuery = "select * from board where "
+keyField+" like '%" + keyWord +"%' order by pos asc";//keyFild컬럼에key 단어를검색위한 sql문
}
rs = stmt.executeQuery(strQuery);//sql문실행하고 결과값ResultSet 객체타입으로 반환
while (rs.next()) {//SQL문 결과 행의 존재여부
BoardBean tempBean = new BoardBean();
//SQL문결과값을tempBoard객체에 저장
tempBean.setNum(rs.getInt("num"));
tempBean.setName(rs.getString("name"));
tempBean.setEmail(rs.getString("email"));
tempBean.setHomepage(rs.getString("homepage"));
tempBean.setSubject(rs.getString("subject"));
tempBean.setContent(rs.getString("content"));
tempBean.setPos(rs.getInt("pos"));
tempBean.setDepth(rs.getInt("depth"));
tempBean.setRegdate(rs.getString("regdate"));
tempBean.setPass(rs.getString("pass"));
tempBean.setCount(rs.getInt("count"));
boardList.addElement(tempBean);

}
}catch(Exception ex){
System.out.println("Exception" + ex);//예외발생하면 내용을 실행창에 표시
}finally{
pool.freeConnection(con,stmt,rs);
}
return boardList;//Vector타입반환 지정
}

public void insertBoard(BoardBean boardBean){
Connection con = null;
PreparedStatement pstmt = null;
upPos();//upPos()메소드 호출

try {
con = pool.getConnection();
String strQuery = "insert into board"
+ "(name,email,homepage,subject,content,pos,depth,regdate,pass,count,ip)"
+ " values(?,?,?,?,?,?,?,NOW(),?,?,?)";//INSERT SQL문 선언

pstmt = con.prepareStatement(strQuery);
pstmt.setString(1,boardBean.getName());
pstmt.setString(2,boardBean.getEmail());
pstmt.setString(3,boardBean.getHomepage());
pstmt.setString(4,boardBean.getSubject());
pstmt.setString(5,boardBean.getContent());
pstmt.setInt(6,boardBean.getPos());
pstmt.setInt(7,boardBean.getDepth());
pstmt.setString(8,boardBean.getPass());
pstmt.setInt(9,boardBean.getCount());
pstmt.setString(10,boardBean.getIp());
pstmt.executeUpdate();//SQL문실행

}catch(Exception ex) {
System.out.println("Exception" + ex);
}finally{
pool.freeConnection(con,pstmt);
}
}

public void upPos(){
Connection con = null;
Statement stmt = null;

try{
con = pool.getConnection();
stmt=con.createStatement();
String strQuery="update board set pos=pos+1";//현제저장된계시물의POS 값을 1씩증가
stmt.executeUpdate(strQuery);//SQL문을 실행
}catch(Exception ex) {
System.out.println("Exception" + ex);
}finally{
pool.freeConnection(con,stmt);
}
}

public BoardBean getBoard(int num) {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
upCount(num);//public BoardBean getBoard(int num) {에서받은 매개변수로upCount()메소드 호출
BoardBean tempBean = new BoardBean();//SQL문저장하기위해 BoardBean객체셍성

try {
con = pool.getConnection();
String strQuery = "select * from board where num = ?";
pstmt = con.prepareStatement(strQuery);
pstmt.setInt(1,num);//매개변수로 받은값을 num = ?";에대입
rs = pstmt.executeQuery();
while (rs.next()) {
//SQL문결과값을setXxx메소드로tempBean객체에저장
tempBean.setNum(rs.getInt("num"));
tempBean.setName(rs.getString("name"));
tempBean.setEmail(rs.getString("email"));
tempBean.setHomepage(rs.getString("homepage"));
tempBean.setSubject(rs.getString("subject"));
tempBean.setContent(rs.getString("content"));
tempBean.setPos(rs.getInt("pos"));
tempBean.setDepth(rs.getInt("depth"));
tempBean.setRegdate(rs.getString("regdate"));
tempBean.setPass(rs.getString("pass"));
tempBean.setCount(rs.getInt("count"));
tempBean.setIp(rs.getString("ip"));
}
}catch(Exception ex) {
System.out.println("Exception" + ex);
}finally{
pool.freeConnection(con,pstmt,rs);
}
return tempBean;
}
//잃기폼
public void upCount(int num) {
Connection con = null;
PreparedStatement pstmt = null;

try{
con = pool.getConnection();
String strQuery="update board set count=count+1 where num= ?";//읽은계시물count값을 증가
pstmt = con.prepareStatement(strQuery);
pstmt.setInt(1,num);//매개변수로받은num값을where num= ?";에대입
pstmt.executeUpdate();
}catch(Exception ex) {
System.out.println("Exception" + ex);
}finally{
pool.freeConnection(con,pstmt);
}
}
//삭제폼
public void deleteBoard(int num) {
Connection con = null;
PreparedStatement pstmt = null;

try{
con = pool.getConnection();
String strQuery = "delete from board where num = ?";//게시물삭제를위한 SQL문선언
pstmt = con.prepareStatement(strQuery);
pstmt.setInt(1,num);//매개변수로 받은 num값을num = ?";에대입
pstmt.executeUpdate();
}catch(Exception ex) {
System.out.println("Exception" + ex);
}finally{
pool.freeConnection(con,pstmt);
}
}
//수정폼
public void updateBoard(BoardBean boardBean){
Connection con = null;
PreparedStatement pstmt = null;

try{
con = pool.getConnection();
String strQuery = "update board set "
+ "name=?,email=?,homepage=?,subject=?,content=?"
+ "where num=?";

pstmt = con.prepareStatement(strQuery);
pstmt.setString(1,boardBean.getName());
pstmt.setString(2,boardBean.getEmail());
pstmt.setString(3,boardBean.getHomepage());
pstmt.setString(4,boardBean.getSubject());
pstmt.setString(5,boardBean.getContent());
pstmt.setInt(6,boardBean.getNum());
pstmt.executeUpdate();
}catch(Exception ex) {
System.out.println("Exception" + ex);
}finally{
pool.freeConnection(con,pstmt);
}
}

public void replyupMyBoard(BoardBean reBoardBean) {
Connection con = null;
PreparedStatement pstmt = null;

try{
con = pool.getConnection();
int pos = reBoardBean.getPos();
String strQuery = "update board set pos = pos + 1 where pos > ?";
pstmt = con.prepareStatement(strQuery);
pstmt.setInt(1,pos);
pstmt.executeUpdate();
}catch(Exception ex) {
System.out.println("Exception" + ex);
}finally{
pool.freeConnection(con,pstmt);
}
}
//답변폼
public void replyMyBoard(BoardBean reBoardBean){
Connection con = null;
PreparedStatement pstmt = null;

try{
con = pool.getConnection();
int depth = reBoardBean.getDepth() + 1;
int pos = reBoardBean.getPos()+1;
String strQuery = "insert into board"
+ "(name,email,homepage,subject,content,pos,depth,regdate,pass,count,ip)"
+ " values (?,?,?,?,?,?,?,NOW(),?,?,?)";

pstmt = con.prepareStatement(strQuery);
pstmt.setString(1,reBoardBean.getName());
pstmt.setString(2,reBoardBean.getEmail());
pstmt.setString(3,reBoardBean.getHomepage());
pstmt.setString(4,reBoardBean.getSubject());
pstmt.setString(5,reBoardBean.getContent());
pstmt.setInt(6,pos);
pstmt.setInt(7,depth);
pstmt.setString(8,reBoardBean.getPass());
pstmt.setInt(9,reBoardBean.getCount());
pstmt.setString(10,reBoardBean.getIp());
pstmt.executeUpdate();

}catch(Exception ex) {
System.out.println("Exception" + ex);
}finally{
pool.freeConnection(con,pstmt);
}
}
}
------------------

List.jsp

<%@ page contentType="text/html; charset=EUC-KR"%>
<%@ page import="ch12.*,java.util.*"%>

<jsp:useBean id="myDB" class="ch12.BoardMgr" />
<%
  request.setCharacterEncoding("euc-kr");
%>
<%
    int totalRecord = 0;  //전체레코트수
    int numPerPage = 15;  //페이지 당 레코트수
    int pagePerBlock =10; //불록당 페이지수
    int totalPage = 0;    //전체페이지수
    int totalBlock = 0;   //전체불록수
    int nowPage = 0;      //현재 페이지
    int nowBlock = 0;     //현재불록
    int beginPerPage =0;  //페이지의 시작번호
    String keyField ="" ; //검색필드
    String keyWord ="" ;  //검색어
    Vector boardList;    //getBoardLis() 메소드의 리턴타입을 Vector로 선언합니다
%>
<%
   if(request.getParameter("keyWord") !=null){
 keyWord =request.getParameter("keyWord");
 keyField =request.getParameter("keyField");
 }
  
 if(request.getParameter("reload") !=null){
 if(request.getParameter("reload").equals("true")){
 keyWord ="";
 keyField ="";
 }
 }

 boardList= myDB.getBoardList(keyField,keyWord);//keyField와keyWord매개변수로 전체게시물을 리턴함
 
 totalRecord = boardList.size(); //Vector 클래스의size()전체게시물의 레코트수를 리턴함
 
 if (request.getParameter("page") != null) {
 nowPage= Integer.parseInt(request.getParameter("page")); } //현제페이지의 계산
 beginPerPage = nowPage * numPerPage;//페이지별 게시물의 시작번호 계산
 totalPage =(int)Math.ceil((double)totalRecord / numPerPage);
 
 if (request.getParameter("nowBlock") != null)
 {nowBlock = Integer.parseInt(request.getParameter("nowBlock"));}//현재불록 계산
 totalBlock =(int)Math.ceil((double)totalPage / pagePerBlock);

%>

<html>
<head><title>계시판</title>
<link href="style.css" rel="stylesheet" type="text/css">
  <script>
    function check() {
    if (document.search.keyWord.value == "")
 {
 alert("검색어를 입력하세요.");
 document.search.keyWord.focus();
 return;
 }
 document.search.submit();
 }

    function list(){
 document.list.action="List.jsp";
  document.list.submit();
 }

    function read(value){
 document.read.action="Read.jsp";
 document.read.num.value=value;
 document.read.submit();  
 }
    </script>
    </head>
    <body>
    <center><br>
    <h2>계시판<br>
    </h2>
    <table width="450" border="0" align="center" cellpadding="1" cellspacing="1">
    <tr>
    <td align="left" >총 : <%=totalRecord%> 개의 게시물이 있습니다.
    (<font color="red"><%=nowPage+1%>/<%=totalPage%>페이지</font>)</td>
    </tr>
    </table>
    <table align="center" width="450" border="0" cellspacing="1" cellpadding="4">
    <tr>
    <td height="126" align="center" valign="top" >
<%
    if (boardList.isEmpty()) {
%>
    등록된 글이 없습니다.
<%  }
    else {
%>
<!------ 상단 메뉴 끝 --------->
    <table border="0" width="100%" cellpadding="2" cellspacing="0">
    <tr align="center" bgcolor="#D0D0D0" height="100%">
    <td width="10%" bgcolor="#00FFFF">번 호</td>
 <td width="43%" bgcolor="#00FFFF">제 목</td>
 <td width="14%" bgcolor="#00FFFF">글쓴이</td>
 <td width="13%" bgcolor="#00FFFF">조회</td>
 <td width="20%" bgcolor="#00FFFF">작성일</td>
    </tr>
<%
 for (int i = beginPerPage;i < (beginPerPage+numPerPage); i++) {
 if (i==totalRecord) break;
 BoardBean tempBoard = (BoardBean)boardList.elementAt(i);
 String name =tempBoard.getName();
 String subject = tempBoard.getSubject();
 String email = tempBoard.getEmail();
 String regdate = tempBoard.getRegdate();
 int depth = tempBoard.getDepth();
 int num = tempBoard.getNum();
 int count =tempBoard.getCount();
%>
    <tr>
    <td align="center" bgcolor="#F0F7FA"><%= totalRecord - i %></td>
    <td bgcolor="#F0F7FA">
<%
 if (depth > 0) {
 for (int re = 0; re < depth; re++) {
%>
    &nbsp;&nbsp;
<%
  }
   }
%>
    <a href="javascript:read('<%=num%>')"><%= subject %></a></td>
    <td align="center" bgcolor="#F0F7FA"><a href="mailto:<%=email %>"><%= name %></a></td>
    <td align="center" bgcolor="#F0F7FA"><%=count%></td>
    <td align="center" bgcolor="#F0F7FA"><%=regdate%></td>
    </tr>
<%
   }
%>
    </table>
    <table width="100%" border="0">
    <tr bgcolor="#F0F7FA">
    <td align="center">
    <a href="Post.jsp" ></a>
 <% if(totalRecord !=0){ %>
    <% if (nowBlock > 0) {%>
    <a href="List.jsp?nowBlock=<%=nowBlock - 1 %>&page=<%=((nowBlock - 1) * pagePerBlock) %>">
 이전<%=pagePerBlock %> 개</a>
<%}%>
<%

    for (int i = 0; i < pagePerBlock; i++) { %>
 [<a href="List.jsp?nowBlock=<%=nowBlock %>&page=<%=(nowBlock*pagePerBlock) + i %>"><%=(nowBlock * pagePerBlock) + i + 1 %></a>]

<% 
 if ((nowBlock * pagePerBlock) + i + 1 == totalPage)break; %><%}
%>

<% 
 if (totalBlock > nowBlock + 1){
%>
    <a href="List.jsp?nowBlock=<%=nowBlock + 1 %>&page=<%=((nowBlock + 1) * pagePerBlock) %>">
 다음 <%=pagePerBlock %>개</a>

<%}%>
<%} %>    </td>
    <td align="right">
 <a href="Post.jsp" >[글쓰기]</a></td>
    </tr>
    </table>
    <p>

<%
   }
%>
    </p>
    </td>
    </tr>
    </table>
<!-- =============================== 검색폼 =============================== -->
<form action="List.jsp" name="search" method="post">
      <table border="0" width="450" align="center" cellpadding="4" cellspacing="1" >
    <tr>
    <td align="center" valign="bottom">
    <select name="keyField" size="1" >
    <option value="name"> 글쓴이
    <option value="subject"> 제 목
    <option value="content"> 내 용
    </select>
    <input type="text" size="16" name="keyWord"  value="">
    <input type="button"  value="찾기" onClick="check()">
    <input type="hidden" name="page" value="0">
    </td>
    </tr>
    </table>
    </form>
    <form name="read" method="post">
    <input type="hidden" name="num" value="">
    <input type="hidden" name="page" value="<%=nowPage%>">
    <input type="hidden" name="keyField" value="<%=keyField%>">
    <input type="hidden" name="keyWord" value="<%=keyWord%>">
    </form>
    <form name="list" method="post">
    <input type="hidden" name="reload" value="true">
    <input type="hidden" name="page" value="0">
    <input type="hidden" name="nowBlock" value="0">
    </form>
</center>
</body>
</html>
--------------------------

Read.jsp

<%@ page contentType="text/html; charset=EUC-KR"%>
<%@ page import="ch12.*"%>

<jsp:useBean id="myDB" class="ch12.BoardMgr" />
<jsp:useBean id="utilMgr" class="ch12.UtilMgr"/>
<%
 int num = Integer.parseInt(request.getParameter("num"));
 int nowPage = Integer.parseInt(request.getParameter("page"));
 String keyField = request.getParameter("keyField");
    String keyWord = request.getParameter("keyWord");
 BoardBean tempBoard = myDB.getBoard(num); 
 String name = tempBoard.getName();
 String email = tempBoard.getEmail();
 String homepage = tempBoard.getHomepage();
 String subject = tempBoard.getSubject();
 String regdate = tempBoard.getRegdate();
 String content = tempBoard.getContent();
 String ip = tempBoard.getIp();
 int count= tempBoard.getCount();
   
   
%>
<html>
<head><title>글읽기</title>
<link href="style.css" rel="stylesheet" type="text/css">

  <script>
    function list(){
 document.list.action="List.jsp";
  document.list.submit();
 }
</script>

</head>
<body>
<br><br>
<table width="450" border="0" align="center">
  <tr>
    <td height="25" colspan="4" bgcolor="9CA2EE">
 <span class="m">글내용 보기</span></td>
  </tr>
    <tr>
    <td colspan="2" bgcolor="#E0EFF4">글쓴이 :<%=name%></td>
    <td width="109" bgcolor="#E0EFF4">작성일 :<%=regdate%></td>
    <td width="97" bgcolor="#E0EFF4">메 일: <a href="mailto:<%=email%>"><%=email%></a></td>
    </tr>
    <tr>
    <td colspan="4" bgcolor="#E0EFF4">홈페이지 :
 <a href="http://<%=homepage%>" target="_new">http://<%=homepage%></a></td>
    </tr>
    <tr>
    <td colspan="4" bgcolor="#E0EFF4">제 목:
 <%=subject%> </td>
    </tr>
    <tr>
    <td colspan="4" bgcolor="#F0F7FA">
 <%=utilMgr.getContent(content)%><br></td>
    </tr>
    <tr>
    <td colspan="4" align="right" bgcolor="#F0F7FA">
 <%=ip%>로 부터 글을 남기셨습니다./조회수
 <%=count%> </td>
    </tr>
    <tr>
    <td width="75" bgcolor="#F0F7FA">[다음글△] :</td>
    <td colspan="3" bgcolor="#F0F7FA"><a href="List.jsp?idx=<%=num%>"><%= subject %></a></td>
    </tr>
    <tr>
    <td bgcolor="#F0F7FA">[이전글▽] :</a> </a></td>
    <td colspan="3" bgcolor="#F0F7FA"><a href="List.jsp?idx=<%=num%>"><%= subject %></a></td>
    </tr>
    <tr>
    <td height="25" colspan="4" align="center" bgcolor="9CA2EE">[ <a href="Reply.jsp?page=<%=nowPage%>&num=<%=num%>" >답변쓰기</a> ]
    [ <a href="Update.jsp?page=<%=nowPage%>&num=<%=num%>" >수정하기</a> ]
    [ <a href="Delete.jsp?page=<%=nowPage%>&num=<%=num%>">삭제하기</a> ]
    [ <a href="javascript:list()" >목록보기</a>]</td>
    </tr>
    </table>
<%
    if(keyWord==null || keyWord.equals("null")){ %>
    <form name="list" method="post">
    <input type="hidden" name="num" value="<%=num%>">
    <input type="hidden" name="page" value="<%=nowPage%>">
    </form>
  <%} else{ %>
    <form name="list" method="post">
    <input type="hidden" name="num" value="<%=num%>">
    <input type="hidden" name="page" value="<%=nowPage%>">
    <input type="hidden" name="keyField" value="<%=keyField%>">
    <input type="hidden" name="keyWord" value="<%=keyWord%>">
    </form>
  <%}%>
</body>
</html>-

제발좀 해결해주세요

 



profile_image 익명 작성일 -

/*
 이 메소드가 한개의 글을 읽는 메소드군요.
 그러나 뭐가 잘못됐죠? . 글 한개만 셀렉트 하는군요...
 이러면 이전글 다음글을 표시할수가 없죠. 현재글만 DB에서 가져오니까요.
 이전글과 다음글의 개념은 현재 글보다 작은것중 가장 num이 큰것과 현재글보다 num이 크면서 num이 작은것을 셀렉트 해야합니다.

 select * from board where num > ?

 많이 사용되는 mysql , oracle , mssql 중 한가지라고 생각하고 쿼리를 만들었습니다. 세개에서 다 돌아갑니다.

 select * from board
 where num in (
   (select  
     max(num)
     from  board
     where num < 5
    )
    ,
    5
    ,
    (select  
    min(num)
    from  board
    where num > 5
    )
       )
 order by num asc

 이렇게 하면 전글이 지워지든 뭐든 작으면서 큰 글 한개, 현재 보는 글 ,  크면서 작은 글 한개 즉 이전글과 다음글을 셀렉트 합니다.

 없는 경우도 생각해봐요 글 1번 글이라면 이전글이 없고 , 마지막 글이면 다음글이 없겠죠?

 따라서 JDBC로 결과값을 빈객체로 가져올경우 세개 중 num값 보다 작은게 이전글 , 크면 다음글입니다. 객체의 수로 판별하면 되구요.

*/

 

public Map getBoard(int num) {
 Connection con = null;
 PreparedStatement pstmt = null;
 ResultSet rs = null;
 upCount(num);//public BoardBean getBoard(int num) {에서받은 매개변수로upCount()메소드 호출
 
 Map map = new HashMap();
 try {
  con = pool.getConnection();
  String strQuery = "select * from board  where num in (   (select       max(num)     from  board      where num < ?    )    ,    ?    ,    (select      min(num)    from  board     where num > ?    )       ) order by num asc";
  pstmt = con.prepareStatement(strQuery);
  pstmt.setInt(1,num);//매개변수로 받은값을 num = ?";에대입
  pstmt.setInt(2,num);//매개변수로 받은값을 num = ?";에대입
  pstmt.setInt(3,num);//매개변수로 받은값을 num = ?";에대입
  rs = pstmt.executeQuery();
  while (rs.next()) {
   BoardBean tempBean = new BoardBean();//SQL문저장하기위해 BoardBean객체셍성
   //SQL문결과값을setXxx메소드로tempBean객체에저장
   int temp_Num = rs.getInt("num");
   tempBean.setNum(temp_Num);
   tempBean.setName(rs.getString("name"));
   tempBean.setEmail(rs.getString("email"));
   tempBean.setHomepage(rs.getString("homepage"));
   tempBean.setSubject(rs.getString("subject"));
   tempBean.setContent(rs.getString("content"));
   tempBean.setPos(rs.getInt("pos"));
   tempBean.setDepth(rs.getInt("depth"));
   tempBean.setRegdate(rs.getString("regdate"));
   tempBean.setPass(rs.getString("pass"));
   tempBean.setCount(rs.getInt("count"));
   tempBean.setIp(rs.getString("ip"));
   if(temp_Num < num)
   {
    map.put("pre",tempBean);
   }
   else if(temp_Num > num)
   {
    map.put("next",tempBean);
   }
   else
    map.put("current",tempBean);
  }
 }catch(Exception ex) {
  System.out.println("Exception" + ex);
 }finally{
  pool.freeConnection(con,pstmt,rs);
 }
 return map;
}

 

 

//getBoard() 함수 변경입니다.... 막코딩이라 약간의 코딩 에러가 있을수 있습니다. DB가 없어서...

 

 

Read.jsp

<%@ page contentType="text/html; charset=EUC-KR"%>
<%@ page import="ch12.*,java.util.*"%>

<jsp:useBean id="myDB" class="ch12.BoardMgr" />
<jsp:useBean id="utilMgr" class="ch12.UtilMgr"/>
<%
 int num = Integer.parseInt(request.getParameter("num"));
 int nowPage = Integer.parseInt(request.getParameter("page"));
 String keyField = request.getParameter("keyField");
    String keyWord = request.getParameter("keyWord");

 Map map = myDB.getBoard(num); 
 BoardBean tempBoard = (BoardBean)map.get("current"); 
 String name = tempBoard.getName();
 String email = tempBoard.getEmail();
 String homepage = tempBoard.getHomepage();
 String subject = tempBoard.getSubject();
 String regdate = tempBoard.getRegdate();
 String content = tempBoard.getContent();
 String ip = tempBoard.getIp();
 int count= tempBoard.getCount();

BoardBean preBoard = (BoardBean)map.get("pre"); 

BoardBean nextBoard = (BoardBean)map.get("next"); 
   
   
%>
<html>
<head><title>글읽기</title>
<link href="style.css" rel="stylesheet" type="text/css">

  <script>
    function list(){
 document.list.action="List.jsp";
  document.list.submit();
 }
</script>

</head>
<body>
<br><br>
<table width="450" border="0" align="center">
  <tr>
    <td height="25" colspan="4" bgcolor="9CA2EE">
 <span class="m">글내용 보기</span></td>
  </tr>
    <tr>
    <td colspan="2" bgcolor="#E0EFF4">글쓴이 :<%=name%></td>
    <td width="109" bgcolor="#E0EFF4">작성일 :<%=regdate%></td>
    <td width="97" bgcolor="#E0EFF4">메 일: <a href="mailto:<%=email%>"><%=email%></a></td>
    </tr>
    <tr>
    <td colspan="4" bgcolor="#E0EFF4">홈페이지 :
 <a href="http://<%=homepage%>" target="_new">http://<%=homepage%></a></td>
    </tr>
    <tr>
    <td colspan="4" bgcolor="#E0EFF4">제 목:
 <%=subject%> </td>
    </tr>
    <tr>
    <td colspan="4" bgcolor="#F0F7FA">
 <%=utilMgr.getContent(content)%><br></td>
    </tr>
    <tr>
    <td colspan="4" align="right" bgcolor="#F0F7FA">
 <%=ip%>로 부터 글을 남기셨습니다./조회수
 <%=count%> </td>
    </tr>
    <tr>
    <td width="75" bgcolor="#F0F7FA">[다음글△] :</td>
    <td colspan="3" bgcolor="#F0F7FA">

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

              <a href="List.jsp?idx=<%=preBoard.getNum()%>">

              <%= preBoard.getSubject() %></a>

       <%   }else{  %> 다음글이 없습니다.

       <% } %>

    </td>
    </tr>
    <tr>
    <td bgcolor="#F0F7FA">[이전글▽] :</a> </a></td>
    <td colspan="3" bgcolor="#F0F7FA">

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

              <a href="List.jsp?idx=<%=nextBoard.getNum()%>">

              <%= nextBoard.getSubject() %></a>

       <%   }else{  %> 이전글이 없습니다.

       <% } %>

    </td>
    </tr>
    <tr>
    <td height="25" colspan="4" align="center" bgcolor="9CA2EE">[ <a href="Reply.jsp?page=<%=nowPage%>&num=<%=num%>" >답변쓰기</a> ]
    [ <a href="Update.jsp?page=<%=nowPage%>&num=<%=num%>" >수정하기</a> ]
    [ <a href="Delete.jsp?page=<%=nowPage%>&num=<%=num%>">삭제하기</a> ]
    [ <a href="javascript:list()" >목록보기</a>]</td>
    </tr>
    </table>
<%
    if(keyWord==null || keyWord.equals("null")){ %>
    <form name="list" method="post">
    <input type="hidden" name="num" value="<%=num%>">
    <input type="hidden" name="page" value="<%=nowPage%>">
    </form>
  <%} else{ %>
    <form name="list" method="post">
    <input type="hidden" name="num" value="<%=num%>">
    <input type="hidden" name="page" value="<%=nowPage%>">
    <input type="hidden" name="keyField" value="<%=keyField%>">
    <input type="hidden" name="keyWord" value="<%=keyWord%>">
    </form>
  <%}%>
</body>
</html>-

 

 

JSP 도 .. 막코딩이라 붙여넣기 하지 마시고 어떤식으로 짯는지 보시고 해보세요....

 

 

profile_image 익명 작성일 -

<%

 BoardBean prevBoard = myDB.getBoard(num+1); 

 BoardBean nextBoard = myDB.getBoard(num-1); 

if(prevBoard.getNum() != 0){

%>

<tr>

<td width="75" bgcolor="#F0F7FA">[다음글△] :</td>
    <td colspan="3" bgcolor="#F0F7FA"><a href="Read.jsp?num=<%=prevBoard.getNum()%>"><%= prevBoard.getSubject() %></a></td>
    </tr>

<%}

if(nextBoard.getNum() != 0){

%>
    <tr>
    <td bgcolor="#F0F7FA">[이전글▽] :</a> </td>

   <td><a href="read.jsp?num=<%=nextBoard.getNum()%>"><%=netxBoard.getSubject()%></a>
</tr>

<%}%>

로그인 할수있게 만드는법

... 압축을 풀면 bbs 이라는 디렉토리가 생성이 됩니다. 2. bbs 디렉토리를 자신의... 스킨 형식 설정 : 만약 일반적인 게시판처럼 목록에 제목만 나오는 경우에는 [게시판...