JSP - 10Àϳ¯ (1203)
-jsp·Î ¹æ¸í·Ï¸¸µé±â-¾²±â .»èÁ¦. ¼öÁ¤. ´ÙÀ½ÆäÀÌÁö
************************************************************
<pre>
***À̺À¿ë´ÔÀÌ Á¦°øÇÑÀÚ·áÀÔ´Ï´Ù.***
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: guestbook.sql ----------------------------------- create table guestbook( seq int auto_increment primary key, name varchar(20), email varchar(50), home varchar(50), passwd varchar(20), content text not null, now_date varchar(10), ip varchar(20) ); insert into guestbook values(\,a,a,a,a,a,a,a);
create table guestreply( replynum int auto_increment primary key, seq int, replyname varchar(20), replycontent text, replydate varchar(10), replypasswd varchar(15) );
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: list.jsp ----------------------------------- <%@ include file=db.jsp %> <%@ include file=
epcontent.jsp %> <%@ page import=java.sql.*,java.io.* ,java.text.* ,java.util.* contentType= ext/html;charset=euc-kr %> <%! int no = 0;//±Û ¹øÈ£ int total_record = 0;//Àüü ±Û¼ö int block = 0;//ÇöÀç ºí·Ï int total_block = 0;//Àüü ºí·Ï int total_page=0;//Àüü ÆäÀÌÁö int page_size = 3;//ÇÑÆäÀÌÁö¿¡ º¸¿©ÁÙ ±Û¼ö int block_size = 10;//ÇÑ ºí·ÏÀÇ ¹À½ int cnt_page=0;//ÇöÀç ÆäÀÌÁö int first = 0;//óÀ½ ·¹Äڵ带 °¡Á®¿Ã À§Ä¡ int first_page = 0;// int last_page = 0;// int prev = 0;//ÀÌÀü ¸ñ·Ïº¸±â int next = 0;//´ÙÀ½ ¸ñ·Ïº¸±â int go_page = 0;//º¸¿©ÁÙ ½ÇÁúÀûÀÎ ÇöÀç ÆäÀÌÁö %> <html> <head> <script> function replysendit(form){ ///* if(form.replyname.value == \){ alert(À̸§À» ÀÔ·ÂÇϽÿÀ); form.replyname.focus(); return false; } if(form.replycontent.value == \){ alert(À̸ÞÀÏÀ» ÀÔ·ÂÇϽÿÀ); form.replycontent.focus(); return false; } if(form.replypass.value == \){ alert(ºñ¹øÀ» ÀÔ·ÂÇϽÿÀ); form.replypass.focus(); return false; } //*/ form.submit(); } function open_window(replynum){ url =
eplydelete_prev.jsp?replynum=+replynum; window.open(url,post,width=300,height=150); } </script> </head> <body> <center><h1>¹æ¸í·Ï</h1></center> <% Connection con = null; Statement stmt = null; ResultSet rs,rs1= null;
try{ request.setCharacterEncoding(euc-kr); con = DriverManager.getConnection(dbhost, dbuser, dbpassword); stmt = con.createStatement(); rs1 = stmt.executeQuery(select count(*) from guestbook); if(rs1.next()){ total_record = rs1.getInt(1); } String str = request.getParameter(page);
if(str == null) str = 1; cnt_page = Integer.parseInt(str); first = page_size * (cnt_page - 1); no = total_record - first;
total_page = (int)Math.ceil((double)total_record / page_size );//0 total_block =(int)Math.ceil((double) total_page / block_size);//0 block = (int)Math.ceil((double)cnt_page / block_size);//0
first_page = (block - 1) * block_size; last_page = block * block_size;
prev = first_page; next = last_page + 1; //go_page = first_page + 1;
if(total_block <= block) last_page = total_page;
String sql = select seq,name,email,home,passwd,content,now_date,ip from guestbook order by seq desc limit +first+,+ page_size;
rs = stmt.executeQuery(sql); %> <table width = 500 align = center> <tr> <td align=right> <font color=blue>Total: <%=total_record%>°³ÀÇ ·¹ÄÚµå    (<%= cnt_page%>/<%=total_page %> ÆäÀÌÁö)</font> </td> </tr> </table> <table align = center width=650 border=1> <tr bgcolor=#99CCFF> <td width = 50 align=center><font size=2 face=±¼¸²>¹øÈ£</font></td> <td width = 60 align=center><font size=2 face=±¼¸²>À̸§</font></td> <td width = 250 align=center><font size=2 face=±¼¸²>ȨÆäÀÌÁö</font></td> <td width = 100 align=center><font size=2 face=±¼¸²>ip</font></td> <td width = 90 align=center><font size=2 face=±¼¸²>³¯Â¥</font></td> <td width = 50 align=center><font size=2 face=±¼¸²>¼öÁ¤</font></td> <td width = 50 align=center><font size=2 face=±¼¸²>»èÁ¦</font></td> </tr> </table> <% while(rs.next()) { int seq=rs.getInt(1); String name=rs.getString(2); String email=rs.getString(3); String home=rs.getString(4); String passwd=rs.getString(5); String content=rs.getString(6); content = repcon(content,\
,<br>); String now_date=rs.getString(7); String ip=rs.getString(8);
%> <table align=center width=650> <tr> <table align = center width=650 border=1> <tr> <td width = 50 align=center><font size=2 face=±¼¸²><%= no%></font></td> <td width = 60 align=center><font size=2 face=±¼¸²><a href=mailto:<%= email%>><%= name%></font></td> <td width = 250 align=center><font size=2 face=±¼¸²><%= home%></font></td> <td width = 100 align=center><font size=2 face=±¼¸²><%= ip%></font></td> <td width = 90 align=center><font size=2 face=±¼¸²><%= now_date%></font></td> <td width = 50 align=center><font size=2 face=±¼¸²><a href=update_pre.jsp?seq=<%= seq %>>¼öÁ¤</a></font></td> <td width = 50 align=center><font size=2 face=±¼¸²><a href = delete_pre.jsp?seq=<%= seq %>>»èÁ¦</a></font></td> </tr> <tr> <td colspan = 7 align=left><%= content %></td> </tr> </table> </tr> <% Statement stmt1 = con.createStatement(); rs1 = stmt1.executeQuery(select * from guestreply where seq =+seq); int cnt = 0; while(rs1.next()){ cnt++; int replynum = rs1.getInt(1); String name2 = rs1.getString(3); String replycontent = rs1.getString(4); replycontent = repcon(replycontent,\
,<br>); %> <tr> <table align = center width=650 border=1 bgcolor=#C9C9C9 cellspacing=0> <tr> <td width=130><font color= blue><%= no %></font>ÀÇ <font color=red><%= cnt %></font>¹ø° ´ä±Û</td> <td width = 70><%= name2 %></td> <td width=400> <%= replycontent %></td> <td width = 50 align=center><font size=2 face=±¼¸²><!--<a href =
eplydelete_pre.jsp?replynum=<%= replynum %>>--> <a href=javascript:open_window(<%= replynum %>);>»èÁ¦</a></font></td> </tr> </table> </tr> <% } %> <tr>
<table align = center width=650 bgcolor=#EAFAC9 cellspacing=0> <form name = form1 method =post action=
eply_proc.jsp?seq=<%= seq %>> <tr ><td colspan=4 align=center>´ä±Û´Þ±â</td> </tr> <tr> <td width=50>À̸§</td> <td width=100><input type=text name=replyname></td> <td rowspan=2><textarea cols=50 rows=3 name=replycontent></textarea></td> <td rowspan=2 width=50><input type=button onclick=replysendit(this.form) value=¾²±â ></td> </tr> <tr> <td>ºñ¹ø</td> <td><input type=password name=replypass></td> </tr> </form> </table>
</tr> </table> <% no--; }//while rs1.close(); rs.close(); stmt.close(); con.close(); }catch(SQLException se) { out.println(se.getMessage()); } %> <table align = center width=500 > <tr> <td align = right><a href=write.html >±Û¾²±â</a> </td> </tr> </table>
<table align=center> <tr> <td align = center> <% //if(cntpage > 1){ //front = cntpage - 1; %> <% if(block > 1){ %> <a href = list.jsp?page=<%= prev %> ><font color=blue>prev </font></a> <% } for(go_page= first_page + 1;go_page<=last_page;go_page++){ if(go_page == cnt_page){ %> <font size=2 color=red face=±¼¸²>[<a href = list.jsp?page=<%= go_page %>><font color=red><%= go_page %></font></a>]</font> <% }else{ %> <font size=2 face=±¼¸²>[<a href = list.jsp?page=<%= go_page %>><%= go_page %></a>]</font> <% } } if(block < total_block){ %> <a href = list.jsp?page=<%= next %> ><font color=blue> next</font></a> <% } %> </td> </tr> </table> </body> </html>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: db.jsp ----------------------------------- <% String drivers = org.gjt.mm.mysql.Driver; String dbhost = jdbc:mysql://localhost:3306/jsp_db;
//String dbhost = jdbc:mysql://localhost:3306/jsp_db?useUnicode=true&characterEncoding=Euc-KR;
String dbuser = captain7606; String dbpassword = lby0321; try{ Class.forName(drivers).newInstance(); }catch(ClassNotFoundException e){ out.println(e); } %>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: write.html ----------------------------------- <HTML> <HEAD> <script>
function sendit(form){
if(form.name.value == \){ alert(À̸§À» ÀÔ·ÂÇϽÿÀ); form.name.focus(); return false; } if(form.email.value == \){ alert(À̸ÞÀÏÀ» ÀÔ·ÂÇϽÿÀ); form.email.focus(); return false; } if(form.pass.value == \){ alert(ºñ¹øÀ» ÀÔ·ÂÇϽÿÀ); form.pass.focus(); return false; } //if(form.home.value == form.home.defaultValue || form.home.value.length <=7){ if(form.home.value == \){ alert(ȨÆäÀÌÁö ÁÖ¼Ò¸¦ ÀÔ·ÂÇØÁֽÿÀ); form.home.focus(); return false; }
if(form.content.value == \){ alert(³»¿ëÀ» ÀÔ·ÂÇϽÿÀ); form.content.focus(); return false; } form.submit(); } </script> </HEAD>
<BODY> <br> <h1>¹æ¸í·Ï</h1> <br> <form name = form method = post action=post.jsp> <table width=600><tr><td align=right><a href=list.jsp?page=1>¸ñ·Ïº¸±â</a></td></tr> </table> <table border=1 width=600> <tr> <td>ÀÌ ¸§</td> <td><input type=text name=name></td> </tr> <tr> <td>ÀÌ ¸Þ ÀÏ</td> <td><input type=text name=email></td> </tr> <tr> <td>ȨÆäÀÌÁö</td> <td><input type=text name=home ></td> </tr> <tr> <td>ºñ¹Ð¹øÈ£</td> <td><input type=password name=pass></td> </tr> <tr> <td>³» ¿ë</td> <td><textarea name=content rows=10 cols=70></textarea></td> </tr>
<tr> <td colspan=2 align=center> <input type=button value=Àü¼Û onclick=sendit(this.form) ><input type=reset value=Ãë¼Ò> </td> </tr> </BODY> </HTML>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: delete_exec.jsp ----------------------------------- <%@ include file=db.jsp %> <%@ page import=java.sql.*,java.io.* ,java.text.* ,java.util.* contentType= ext/html;charset=euc-kr %>
<% request.setCharacterEncoding(euc-kr); Connection con = null; Statement stmt = null; ResultSet rs= null; String dbpass = null;
int seq = Integer.parseInt(request.getParameter(seq)); String pass = request.getParameter(pass); String query = delete from guestbook where seq = +seq;
try{ con = DriverManager.getConnection(dbhost,dbuser,dbpassword); stmt = con.createStatement(); String query2 = select passwd from guestbook where seq = +seq; rs = stmt.executeQuery(query2); if(rs.next()){ dbpass = rs.getString(1); } if(pass.equals(dbpass)){ stmt.executeUpdate(query); rs.close(); stmt.close(); con.close(); response.sendRedirect(list.jsp); }else{ %>
<script> alert(password°¡ Ʋ¸³´Ï´Ù.); history.back(-1); </script> <% } }catch(Exception e){ out.println(sql error); //}catch(ClassNotFoundException ee){ // out.println(driver error); } %>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: delete_pre.jsp ----------------------------------- <%@ include file=db.jsp %> <%@ include file=
epcontent.jsp %> <%@ page import=java.sql.*,java.io.* ,java.text.* ,java.util.* contentType= ext/html;charset=euc-kr %> <%! String name=null; String email=null; String home=null; //String passwd=rs.getString(5); String content=null; %> <% request.setCharacterEncoding(euc-kr); Connection con = null; Statement stmt = null; ResultSet rs= null;
int seq = Integer.parseInt(request.getParameter(seq));
String query = select * from guestbook where seq = +seq; //String query = select * from guestbook where seq = 148;
try{ con = DriverManager.getConnection(dbhost,dbuser,dbpassword); stmt = con.createStatement(); rs = stmt.executeQuery(query); if(rs.next()){ //int seq=rs.getInt(1); name=rs.getString(2); email=rs.getString(3); home=rs.getString(4); //String passwd=rs.getString(5); content=rs.getString(6); content = repcon(content,\
,<br>); //String now_date=rs.getString(7); //String ip=rs.getString(8); }
stmt.close(); con.close(); //response.sendRedirect(list.jsp); }catch(Exception e){ out.println(sql error); //}catch(ClassNotFoundException ee){ // out.println(driver error); } %>
<html> <head> <script> function start1(){ document.form.pass.focus(); } function sendit(form){
if(form.pass.value == \){ alert(»èÁ¦¸¦ À§ÇÑ ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇϽÿÀ); form.pass.focus(); return false; } form.submit(); } </script> </head> <BODY onload=start1()> <br> <h1>¹æ¸í·Ï</h1> <br> <form name = form method = post action=delete_exec.jsp?seq=<%= seq %> > <table width=600><tr><td align=right><a href=list.jsp?page=1>¸ñ·Ïº¸±â</a></td></tr> </table> <table border=1 width=600> <tr> <td>ÀÌ ¸§</td> <td><%= name %></td> </tr> <tr> <td>ÀÌ ¸Þ ÀÏ</td> <td><%= email %></td> </tr> <tr> <td>ȨÆäÀÌÁö</td> <td><%= home %></td> </tr> <tr> <td>ºñ¹Ð¹øÈ£</td> <td><input type=password name=pass></td> </tr> <tr> <td>³» ¿ë</td> <td><%= content %></td> </tr>
<tr> <td colspan=2 align=center> <input type=button value=»èÁ¦ onclick=sendit(this.form) ><input type=reset value=Ãë¼Ò> </td> </tr> </BODY> </HTML>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: post.jsp ----------------------------------- <%@ include file=db.jsp %> <%@ page import=java.sql.*,java.io.* ,java.text.* ,java.util.* contentType= ext/html;charset=euc-kr %>
<% request.setCharacterEncoding(euc-kr); Connection con = null; Statement stmt = null; ResultSet rs= null;
String name = request.getParameter(
ame).trim(); String email = request.getParameter(email).trim(); String home = request.getParameter(home).trim(); String pass = request.getParameter(pass).trim(); String content = request.getParameter(content).trim(); java.util.Date now = new java.util.Date(); SimpleDateFormat date = new SimpleDateFormat(yyyy/MM/dd); String now_date = date.format(now); String ip = request.getRemoteAddr();
String query = insert into guestbook values(\,\+ name +\,\+email+\,\+home+\,\+pass+\,\+content+\,\+now_date+\,\+ip+\);;
try{ con = DriverManager.getConnection(dbhost,dbuser,dbpassword); stmt = con.createStatement(); stmt.executeUpdate(query);
stmt.close(); con.close(); response.sendRedirect(list.jsp); }catch(Exception e){ out.println(sql error); //}catch(ClassNotFoundException ee){ // out.println(driver error); } %>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: repcontent.jsp ----------------------------------- <%! String repcon(String str,String n1,String n2){ int itmp = 0; if(str == null) return \; String tmp = str; StringBuffer sb = new StringBuffer(); sb.append(\);
while(tmp.indexOf(n1) > -1){ itmp = tmp.indexOf(n1); sb.append(tmp.substring(0,itmp)); sb.append(n2); tmp = tmp.substring(itmp+n1.length()); } sb.append(tmp); return sb.toString(); } %>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: reply_proc.jsp ----------------------------------- <%@ include file=db.jsp %> <%@ page import=java.sql.*,java.io.* ,java.text.* ,java.util.* contentType= ext/html;charset=euc-kr %>
<% request.setCharacterEncoding(euc-kr); Connection con = null; Statement stmt = null; ResultSet rs= null;
int seq = Integer.parseInt(request.getParameter(seq).trim()); String replyname = request.getParameter(
eplyname).trim(); String replypass = request.getParameter(
eplypass).trim(); String replycontent = request.getParameter(
eplycontent).trim(); java.util.Date now = new java.util.Date(); SimpleDateFormat date = new SimpleDateFormat(yyyy/MM/dd); String replydate = date.format(now);
String query = insert into guestreply values(\,+seq+,\+ replyname +\,\+replycontent+\,\+replydate+\,\+replypass+\);;
try{ con = DriverManager.getConnection(dbhost,dbuser,dbpassword); stmt = con.createStatement(); stmt.executeUpdate(query);
stmt.close(); con.close(); response.sendRedirect(list.jsp); }catch(Exception e){ out.println(sql error); //}catch(ClassNotFoundException ee){ // out.println(driver error); } %>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: replydelete_exec.jsp ----------------------------------- <%@ include file=db.jsp %> <%@ page import=java.sql.*,java.io.* ,java.text.* ,java.util.* contentType= ext/html;charset=euc-kr %>
<% request.setCharacterEncoding(euc-kr); Connection con = null; Statement stmt = null; ResultSet rs= null; String dbpass = null;
int replynum = Integer.parseInt(request.getParameter(
eplynum)); String pass = request.getParameter(pass); String query = delete from guestreply where replynum = +replynum;
try{ con = DriverManager.getConnection(dbhost,dbuser,dbpassword); stmt = con.createStatement(); String query2 = select replypasswd from guestreply where replynum = +replynum; rs = stmt.executeQuery(query2); if(rs.next()){ dbpass = rs.getString(1); } if(pass.equals(dbpass)){ stmt.executeUpdate(query); rs.close(); stmt.close(); con.close(); //response.sendRedirect(list.jsp); %> <script> opener.document.location = list.jsp; self.close(); </script> <% }else{ %>
<script> alert(password°¡ Ʋ¸³´Ï´Ù.); history.back(-1); </script> <% } }catch(Exception e){ out.println(sql error); //}catch(ClassNotFoundException ee){ // out.println(driver error); } %>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: replydelete_pre.jsp ----------------------------------- <%@ include file=db.jsp %> <%@ page import=java.sql.*,java.io.* ,java.text.* ,java.util.* contentType= ext/html;charset=euc-kr %>
<% request.setCharacterEncoding(euc-kr); Connection con = null; Statement stmt = null; ResultSet rs= null; String dbpass = null;
int seq = Integer.parseInt(request.getParameter(seq)); String pass = request.getParameter(pass); String query = delete from guestreply where replynum = +replynum;
try{ con = DriverManager.getConnection(dbhost,dbuser,dbpassword); stmt = con.createStatement(); String query2 = select passwd from guestbook where replynum = +replynum; rs = stmt.executeQuery(query2); if(rs.next()){ dbpass = rs.getString(1); } if(pass.equals(dbpass)){ stmt.executeUpdate(query); rs.close(); stmt.close(); con.close(); response.sendRedirect(list.jsp); }else{ %>
<script> alert(password°¡ Ʋ¸³´Ï´Ù.); history.back(-1); </script> <% } }catch(Exception e){ out.println(sql error); //}catch(ClassNotFoundException ee){ // out.println(driver error); } %>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: replydelete_prev.jsp ----------------------------------- <%@ page import=java.sql.*,java.io.* ,java.text.* ,java.util.* contentType= ext/html;charset=euc-kr %>
<% request.setCharacterEncoding(euc-kr); String replynum = request.getParameter(
eplynum); %> <html> <head> <script> function sendform(form){ if(form.pass.value==\){ alert(ºñ¹ø À» ÀÔ·ÂÇϽÿÀ); form.pass.focus(); return false; } form.submit(); //self.close(); } </script> </head> <body> <form name = form method=post action =
eplydelete_exec.jsp?replynum=<%=replynum %>> <table>
<tr><td>ºñ¹Ð¹øÈ£</td> <td><input type=password name=pass></td> </tr> <tr> <td colspan=2 align=center> <input type=button value=»èÁ¦ onclick=sendform(this.form)><input type=reset value=Ãë¼Ò> </td> </tr> </table> </form> </body> </html>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: update_exec.jsp ----------------------------------- <%@ include file=db.jsp %> <%@ page import=java.sql.*,java.io.* ,java.text.* ,java.util.* contentType= ext/html;charset=euc-kr %>
<%! String sql(String str){ return \+str+\; } %> <% request.setCharacterEncoding(euc-kr); Connection con = null; Statement stmt = null; ResultSet rs= null; String dbpass = null;
int seq = Integer.parseInt(request.getParameter(seq)); String name = request.getParameter(
ame).trim(); String email = request.getParameter(email).trim(); String home = request.getParameter(home).trim(); String pass = request.getParameter(pass).trim(); String content = request.getParameter(content).trim(); java.util.Date now = new java.util.Date(); SimpleDateFormat date = new SimpleDateFormat(yyyy/MM/dd); String now_date = date.format(now); String ip = request.getRemoteAddr();
//String query = update guestbook set name = \+name+\,email = \+email+\,home = \+home+\,content = \+content+\,passwd = \+pass+\,now_date = \+now_date+\,ip = \+ip+\ where seq = +seq + and passwd = \+pass+\;
String query = update guestbook set name = +sql(name)+,email = +sql(email)+,home = +sql(home)+,content = +sql(content)+,passwd = +sql(pass)+,now_date = +sql(now_date)+,ip = +sql(ip)+ where seq = +seq + and passwd = +sql(pass);
try{ con = DriverManager.getConnection(dbhost,dbuser,dbpassword); stmt = con.createStatement(); //stmt.executeUpdate(query);
String query2 = select passwd from guestbook where seq = +seq; rs = stmt.executeQuery(query2); if(rs.next()) dbpass = rs.getString(1); if(pass.equals(dbpass)){ stmt.executeUpdate(query); rs.close(); stmt.close(); con.close(); response.sendRedirect(list.jsp); }else{ %> <script> alert(password°¡ Ʋ¸³´Ï´Ù.); history.back(-1); </script> <% }
}catch(Exception e){ out.println(sql error); //}catch(ClassNotFoundException ee){ // out.println(driver error); } %>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: update_pre.jsp ----------------------------------- <%@ include file=db.jsp %> <%@ page import=java.sql.*,java.io.* ,java.text.* ,java.util.* contentType= ext/html;charset=euc-kr %> <%! String name=null; String email=null; String home=null; //String passwd=rs.getString(5); String content=null; %> <% request.setCharacterEncoding(euc-kr); Connection con = null; Statement stmt = null; ResultSet rs= null;
int seq = Integer.parseInt(request.getParameter(seq));
String query = select * from guestbook where seq = +seq; //String query = select * from guestbook where seq = 148;
try{ con = DriverManager.getConnection(dbhost,dbuser,dbpassword); stmt = con.createStatement(); rs = stmt.executeQuery(query); if(rs.next()){ //int seq=rs.getInt(1); name=rs.getString(2); email=rs.getString(3); home=rs.getString(4); //String passwd=rs.getString(5); content=rs.getString(6); //content = repcon(content,\
,<br>); //String now_date=rs.getString(7); //String ip=rs.getString(8); }
stmt.close(); con.close(); //response.sendRedirect(list.jsp); }catch(Exception e){ out.println(sql error); //}catch(ClassNotFoundException ee){ // out.println(driver error); } %>
<html> <head> <script> function sendit(form){
if(form.pass.value == \){ alert(¼öÁ¤À» À§ÇÑ ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇϽÿÀ); form.pass.focus(); return false; } form.submit(); } </script> </head> <BODY onload=javascript:document.form.pass.focus()> <br> <h1>¹æ¸í·Ï</h1> <br> <form name = form method = post action=update_exec.jsp?seq=<%= seq %>> <table width=600><tr><td align=right><a href=list.jsp?page=1>¸ñ·Ïº¸±â</a></td></tr> </table> <table border=1 width=600> <tr> <td>ÀÌ ¸§</td> <td><input type=text name=name value=<%= name %>></td> </tr> <tr> <td>ÀÌ ¸Þ ÀÏ</td> <td><input type=text name=email value = <%= email %>></td> </tr> <tr> <td>ȨÆäÀÌÁö</td> <td><input type=text name=home value = <%= home %>></td> </tr> <tr> <td>ºñ¹Ð¹øÈ£</td> <td><input type=password name=pass></td> </tr> <tr> <td>³» ¿ë</td> <td><textarea name=content rows=10 cols=70 ><%= content %></textarea></td> </tr>
<tr> <td colspan=2 align=center> <input type=button value=¼öÁ¤ onclick=sendit(this.form) ><input type=reset value=Ãë¼Ò> </td> </tr> </BODY> </HTML>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
JSP½ºÅ͵ð 2004 12 03
¼Ò½ºÀÚ¼¼È÷º¸±â http://www.6VJ.com/jsp/jap1203.txt ´õÀÚ¼¼È÷´Â ¿À¸¥Âʸ¶¿ì½º·Î ¼Ò½ºº¸±â
</pre>
************************************************************
***À̺À¿ë´ÔÀÌ Á¦°øÇÑÀÚ·áÀÔ´Ï´Ù.***
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: guestbook.sql ----------------------------------- create table guestbook( seq int auto_increment primary key, name varchar(20), email varchar(50), home varchar(50), passwd varchar(20), content text not null, now_date varchar(10), ip varchar(20) ); insert into guestbook values(\,a,a,a,a,a,a,a);
create table guestreply( replynum int auto_increment primary key, seq int, replyname varchar(20), replycontent text, replydate varchar(10), replypasswd varchar(15) );
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --- ÆÄÀϸí: list.jsp ----------------------------------- <%@ include file=db.jsp %> <%@ include file=
epcontent.jsp %> <%@ page import=java.sql.*,java.io.* ,java.text.* ,java.util.* contentType= ext/html;charset=euc-kr %> <%! int no = 0;//±Û ¹øÈ£ int total_record = 0;//Àüü ±Û¼ö int block = 0;//ÇöÀç ºí·Ï int total_block = 0;//Àüü ºí·Ï int total_page=0;//Àüü ÆäÀÌÁö int page_size = 3;//ÇÑÆäÀÌÁö¿¡ º¸¿©ÁÙ ±Û¼ö int block_size = 10;//ÇÑ ºí·ÏÀÇ ¹À½ int cnt_page=0;//ÇöÀç ÆäÀÌÁö int first = 0;//óÀ½ ·¹Äڵ带 °¡Á®¿Ã À§Ä¡ int first_page = 0;// int last_page = 0;// int prev = 0;//ÀÌÀü ¸ñ·Ïº¸±â int next = 0;//´ÙÀ½ ¸ñ·Ïº¸±â int go_page = 0;//º¸¿©ÁÙ ½ÇÁúÀûÀÎ ÇöÀç ÆäÀÌÁö %>
¹æ¸í·Ï <% Connection con = null; Statement stmt = null; ResultSet rs,rs1= null;
try{ request.setCharacterEncoding(euc-kr); con = DriverManager.getConnection(dbhost, dbuser, dbpassword); stmt = con.createStatement(); rs1 = stmt.executeQuery(select count(*) from guestbook); if(rs1.next()){ total_record = rs1.getInt(1); } String str = request.getParameter(page);
if(str == null) str = 1; cnt_page = Integer.parseInt(str); first = page_size * (cnt_page - 1); no = total_record - first;
total_page = (int)Math.ceil((double)total_record / page_size );//0 total_block =(int)Math.ceil((double) total_page / block_size);//0 block = (int)Math.ceil((double)cnt_page / block_size);//0
first_page = (block - 1) * block_size; last_page = block * block_size;
prev = first_page; next = last_page + 1; //go_page = first_page + 1;
if(total_block <= block) last_page = total_page;
String sql = select seq,name,email,home,passwd,content,now_date,ip from guestbook order by seq desc limit +first+,+ page_size;
rs = stmt.executeQuery(sql); %>
Total: <%=total_record%>°³ÀÇ ·¹ÄÚµå (<%= cnt_page%>/<%=total_page %> ÆäÀÌÁö) |
¹øÈ£ | À̸§ | ȨÆäÀÌÁö | ip | ³¯Â¥ | ¼öÁ¤ | »èÁ¦ |
<% while(rs.next()) { int seq=rs.getInt(1); String name=rs.getString(2); String email=rs.getString(3); String home=rs.getString(4); String passwd=rs.getString(5); String content=rs.getString(6); content = repcon(content,\
, ); String now_date=rs.getString(7); String ip=rs.getString(8);
%>
|