6.ÆäÀÌÁö ¸®½ºÆ® ó¸®(PageList.jsp)

 

ÆäÀÌÁö ¸®½ºÆ® ó¸® ºÎºÐÀº HTML Tag °¡ ºüÁú·¡¾ß ºüÁú¼ö ¾ø´Â ºÎºÐÀÔ´Ï´Ù.

ÀÌ ºÎºÐÀÌ Ä¿½ºÅÒ Å±׳ª ºóÁî·Î 󸮰¡ µÈ´Ù¸é ¾î¶³±î¿ä??

µðÀÚÀÎÀÌ ÀÚÁÖ ¹Ù²î´Â ÆäÀÌÁö¶ó¸é ÀÏÀÏÀÌ Å¬·¡½º¸¦ ã¾Æ¼­ ¹Ù²Ù°í ÄÄÆÄÀÏ ÇÏ´Â °úÁ¤ÀÌ ÀÖ¾î¾ß ÇÕ´Ï´Ù.

 

±×·¡¼­ ÀÌ ºÎºÐÀº JSP ÆäÀÌÁö·Î ó¸® ÇÏ¿´½À´Ï´Ù.

 

·ÎÁ÷¿¡ ´ëÇÑ ¼³¸íÀº »ý·«Çϵµ·Ï ÇÏ°Ú½À´Ï´Ù.(¼Ò½ºÆÄÀÏÀ» ÂüÁ¶ Çϼ¼¿ä)

 

´Ü.. ¿ÜºÎÀÇ JSPÆäÀÌÁö À̹ǷΠ¸®½ºÆ® ÆäÀÌÁö¿¡¼­ ÀÎŬ·çµå ÇÏ´Â ¹æ¹ý¸¸ »ìÆ캸µµ·Ï ÇÏ°Ú½À´Ï´Ù.

 

<list.jsp>

¡¦¡¦¡¦¡¦¡¦

<Áß·«>

¡¦¡¦¡¦¡¦¡¦

<jsp:include page="PageList.jsp" flush="true">

<jsp:param name="PAGE_CNT" value="<%=total_page%>"/>

<jsp:param name="PAGE" value="<%=current_page%>"/>

<jsp:param name="PAGE_SIZE" value="5"/>

<jsp:param name="FIELD" value="<%=field%>"/>

<jsp:param name="KEY" value="<%=key%>"/>

<jsp:param name="URL" value="list.jsp"/>

</jsp:include>

¡¦¡¦¡¦¡¦¡¦

<Áß·«>

¡¦¡¦¡¦¡¦¡¦

 

 

7. ±Û³»¿ë º¸±â ¹× Á¶È¸¼ö Áõ°¡½ÃÅ°±â

 

±Û³»¿ë º¸´Â °Íµµ ¸®½ºÆ®ÆäÀÌÁö¿Í °°Àº ¹æ¹ýÀ¸·Î ó¸®ÇÏ¿´½À´Ï´Ù.

óÀ½¿¡´Â Ŭ·¡½º(ű×Çڵ鷯)¸¦ µû·Î ¸¸µé±î ÇÏ´Â »ý°¢ÇØ º¸¾ÒÁö¸¸ ÆäÀÌÁö¿¡¼­ ½è´ø ¹æ¹ý ±×´ë·Î ½áµµ ¹«¸®°¡ ¾øÀ»°ÍÀ¸·Î »ý°¢µÇ¾î ½À´Ï´Ù.

 

¼Ò½ººÎÅÍ »ìÆ캸°Ú½À´Ï´Ù.


 

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

<%@ taglib uri="taglib" prefix="tl"%>

<jsp:useBean id="NoticeList" class="notice.NoticeList"/>

<%

¡¦¡¦¡¦¡¦¡¦¡¦¡¦

<Áß·«>

¡¦¡¦¡¦¡¦¡¦¡¦¡¦

int no = Integer.parseInt(request.getParameter("NO"));

¡¦¡¦¡¦¡¦¡¦¡¦¡¦

<Áß·«>

¡¦¡¦¡¦¡¦¡¦¡¦¡¦

%>

 

<tl:iterate name="notice" vector="<%=NoticeList.getArticle(no)%>" type="notice.NoticeRec">

<table width=703 cellpadding=0 cellspacing=0 border=0>

<tr height=1 bgcolor="#afafaf">

<td colspan=7><img src="img/clear.gif" height=1 width=1></td>

</tr>

<tr height=25 bgcolor="#f2f2f2">

             <td colspan=7>&nbsp;&nbsp;

<b><jsp:getProperty name="notice" property="subject"/></b></td>

</tr>

<tr height=1 bgcolor="#afafaf">

<td colspan=7><img src="img/clear.gif" height=1 width=1></td>

</tr>

<tr height=25 bgcolor="#f2f2f2" align=center>

                          <td width=175>ÀÛ ¼º ÀÏ</td>

                          <td width=1 background="img/back_verdot3.gif">

            <img src="img/clear.gif" height=1 width=1></td>

                          <td width=175><jsp:getProperty name="notice" property="regi_date"/></td>

                          <td width=1 background="img/back_verdot3.gif">

                        <img src="img/clear.gif" height=1 width=1></td>

                          <td width=175>Á¶È¸¼ö</td>

                          <td width=1 background="img/back_verdot3.gif">

                        <img src="img/clear.gif" height=1 width=1></td>

                          <td width=175><jsp:getProperty name="notice" property="cnt"/></td>

</tr>

</table>

</tl:iterate>

<table width=703 cellpadding=10 cellspacing=0 border=0>

<tr>

             <td width=100%>

             <tl:repString input="\n" replace="<BR>">

<jsp:getProperty name="notice" property="content"/>

</tl:repString>

             </td>

</tr>

</table>

¡¦¡¦¡¦¡¦¡¦¡¦¡¦

<Áß·«>

¡¦¡¦¡¦¡¦¡¦¡¦¡¦

 

¸®½ºÆ®¿Í ´Ù¸¥ Á¡ÀÌ Çϳªµµ ¾øÁÒ??

´Ü.. ±Û ³»¿ëÀ» °¡Á®¿À±â À§ÇÑ »õ·Î¿î ¸Þ¼­µå °¡ Ãß°¡µÈ °Í°ú <BR> ÅÂ±× Ã³¸® ºÎºÐÀÌ µé¾î °£ °Í ¸¸ ´Ù¸£³×¿ä.

 

ÀÌ ¸Þ¼­µå´Â ÆĶó¹ÌÅÍ·Î ±Û ¹øÈ£(index)¸¦ ¹Þ¾Æ¿É´Ï´Ù.

 

<NoticeList.java>

¡¦¡¦¡¦¡¦¡¦¡¦¡¦

<Áß·«>

¡¦¡¦¡¦¡¦¡¦¡¦¡¦

 

/***************************************************

 *

 *                       ±Û³»¿ë º¸±â

 *

 ***************************************************/

              

public Vector getArticle(int no) throws SQLException{

             Connection con = null;

             Statement stmt = null;

             ResultSet rs = null;

            

             Vector v = new Vector();

             String query;   

             int cnt;

                         

             try{

                          NoticeRec nr = new NoticeRec();

                          con = getDBConnection();

                          stmt = con.createStatement();

                          query = "SELECT SUBJECT,CONTENT,REGI_DATE,CNT FROM NOTICE_T WHERE NO = " + no ;

                                      

                          rs = stmt.executeQuery(query);

                          rs.next();

                          nr.subject = rs.getString("SUBJECT");

                          nr.content = rs.getString("CONTENT");

                          nr.regi_date = rs.getString("REGI_DATE");

                          nr.cnt = rs.getInt("CNT");                                                                             

                                      

                          v.addElement(nr);

             }catch(SQLException e){

                          e.getMessage();

             }finally{

                          if(rs != null) rs.close();

                          if(stmt != null) stmt.close();

                          if(con != null) con.close();

             }

             return v;

}

¡¦¡¦¡¦¡¦¡¦¡¦¡¦

<Áß·«>

¡¦¡¦¡¦¡¦¡¦¡¦¡¦

 

 

ÀÌ ¸Þ¼­µåµµ º°°Ç ¾ø±º¿ä.

´Ü¼øÈ÷ ±Û¹øÈ£¸¦ ¹Þ¾Æ¿À°í ±Û¹øÈ£¿¡ ÇØ´çÇÏ´Â µ¥ÀÌÅ͸¦ »Ì¾Æ ¿ÂÈÄ º¤ÅÍ·Î ¸®ÅÏÇÏ´Â°Ô ÀüºÎ ÀÔ´Ï´Ù.

¸» ³ª¿Â±è¿¡ Á¶È¸¼ö Áõ°¡ ½ÃÅ°´Â ¸Þ¼­µå±îÁö ¸¸µé¾î º¸°Ú½À´Ï´Ù.

 

<NoticeList.java>

¡¦¡¦¡¦¡¦¡¦¡¦¡¦

<Áß·«>

¡¦¡¦¡¦¡¦¡¦¡¦¡¦

/***************************************************

 *

 *                       Á¶È¸¼ö Áõ°¡

 *

 ***************************************************/

              

public void incrCnt(int no) throws SQLException{

             Connection con = null;

             PreparedStatement pstmt = null;

            

             try{

                          con = getDBConnection();

            

             pstmt = con.prepareStatement("UPDATE NOTICE_T SET CNT = CNT+1 WHERE NO=?");

                          pstmt.setInt(1,no);

                          pstmt.execute();

                          con.commit();

             }catch(SQLException e){

                          e.getMessage();

             }finally{

                          if(pstmt != null) pstmt.close();

                          if(con != null) pstmt.close();

             }                         

}

¡¦¡¦¡¦¡¦¡¦¡¦¡¦

<Áß·«>

¡¦¡¦¡¦¡¦¡¦¡¦¡¦

 

¿ª½Ã º° °Í ¾ø±º¿ä ^^;;

´Ü.. Statemet °´Ã¼ ´ë½Å PreparedStatment ¸¦ ½è½À´Ï´Ù.

 

À̹ø¿¡´Â ±Û³»¿ëÁß <BR> ű׸¦ ó¸®ÇÒ ¼ö ÀÖµµ·Ï Çϱâ À§ÇØ À¯Æ¿¸®Æ¼ Ŭ·¡½º¸¦ ¸¸µé¾î º¸°Ú½À´Ï´Ù.

À̹ø¿¡ ¸¸µé Ŭ·¡½º´Â ±Û °Ë»ö½Ã¿¡µµ À¯¿ëÇÏ°Ô »ç¿ëµÉ ¼ö ÀÖ½À´Ï´Ù.

 

ÇöÀç ±îÁö ÀÛ¼ºµÈ JSPÆäÀÌÁö·Î °Ë»öÀ» ÇÏ¸é ´Üµû¿ÈÇ¥ 󸮰¡ µÇÁö ¾ÊÀ¸¹Ç·Î ¿¡·¯¸¦ ³»°í ¸¿´Ï´Ù.

ÀÌ Å¬·¡½º¸¦ ¾²¸é ÀÌ·± ¹®Á¦µµ ½±°Ô ÇØ°áÀÌ µË´Ï´Ù.

 



Âü°í ¹®¼­ ¹× »çÀÌÆ®
- ÅÂ±× ¶óÀ̺귯¸® Æ©Å丮¾ó (www.orionsever.com)
- www.webdox.co.kr
- jsp.boolpae.com
- Web Development with JavaServerPages (ÀÎÆ÷ºÏ)
- ¿¹Á¦·Î ¹è¿ì´Â ÀÚ¹Ù ÇÁ·Î±×·¡¹Ö (ÇѺû ¹Ìµð¾î)
- ÆÛÆåÆ® JSP (ÇѺû ¹Ìµð¾î)