1. 程式人生 > >Java web專案 愛分享社群評論管理部分程式碼

Java web專案 愛分享社群評論管理部分程式碼

<%@ page import ="java.sql.*"   %>
<%@ page import ="DAO.*"   %>
<%@ page import ="java.util.*"   %>
<%@ 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>評論管理</title>
</head>
<body>
<STYLE type=text/css> BODY {
	PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px; BACKGROUND-COLOR: #2a8dc8
}
BODY {
	FONT-SIZE: 12px; COLOR: #003366; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
}
TD {
	FONT-SIZE: 12px; COLOR: #003366; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
}
DIV {
	FONT-SIZE: 12px; COLOR: #003366; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
}
P {
	FONT-SIZE: 12px; COLOR: #003366; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
}
</STYLE>

<META content="MSHTML 6.00.2900.3492" name=GENERATOR></HEAD>
<BODY>

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD width=10><IMG src="images/new_001.jpg" border=0></TD>
    <TD background=images/new_002.jpg><FONT size=4><B>評論管理中心
      </B></FONT> </TD>
    <TD background=images/new_002.jpg>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD align=right height=25></TD></TR>
        <TR>
          <TD height=35>
    
    
 <form  action="commentdel.jsp"    >
請輸入要刪除的評論id:<input   type="text"    name="delid"        >
<input  type="submit"     name="submit"      value="提交" /    >
</form>
          <A href="exit.jsp"   target=_top><FONT color=red><B>安全退出</B></FONT></A>       
      </TD></TR>
      

  
 







  
      </TBODY></TABLE></TD>
    <TD width=10><IMG src="images/new_003.jpg" 
border=0></TD></TR></TBODY></TABLE></BODY>
<%
Class.forName("oracle.jdbc.driver.OracleDriver");
 Connection  conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL","system","Oracle11g");
  request.setCharacterEncoding("utf-8"); 
Statement stmt =conn.createStatement();

 
 ArrayList<Comment>  comms =new ArrayList<Comment>();
String sql1 = "select  *  from comm ";      
ResultSet rs=stmt.executeQuery(sql1);
while(rs.next()){
	Comment commtent=new Comment();
	commtent.setCommid(rs.getString("commentid"));
	commtent.setWords(rs.getString("words"));
   commtent.setUsername(rs.getString("username"));
comms.add(commtent);
}
	 stmt.close();
		conn.close();
%>


<table width="990" border="2" style="background:#ccccff">
<tr height="35">
	<td align="left" width="660" colspan="9">此時所有的文章如下:</td>
</tr>
<tr height="30">
	<th>評論id</th>
	<th>評論內容</th>
	<th>使用者名稱</th>

</tr>
<% 
	for(int i=0;i<comms.size();i++){
%>
<tr height="25">
	<td><%=comms.get(i).getCommid()%></td>
	 <td><%=comms.get(i).getWords()%></td>
	<td><%=comms.get(i).getUsername() %></td>
</tr>
<% } %>
</table>


</body>
</html>