JSP article content management and deletion code
<BR/>
requirements Information Management
<HR color= "#0099FF" size= "1"/>
<%
String o P
String delid = Request.getparameter ("ID");
op = Request.getparameter ("op");
if (op==null) {
op = "my";
}
If (Request.getparameter ("SubmitEdit")!=null) {
string namea=new String (request.getparameter ("name"). GetBytes ("iso-8859-1"));
string notea=new String (Request.getparameter ("note"). GetBytes ("iso-8859-1"));
string linka=new String (request.getparameter ("link"). GetBytes ("iso-8859-1"));
string pica=new String (Request.getparameter ("img"). GetBytes ("iso-8859-1"));
statement stmt_add=conn.createstatement ();
stmt_add.executeupdate ("Update hl_links Set name=" "+namea+" ', noten= ' "+notea+" ', link= ' "+linka+" ', pic= ' "+ Pica+ "' Where id=" +delid);
stmt_add.close ();
out.print ("<script type=" Text/javascript "> Alert" Your settings have been successful! "); window.location.href= ' xq_manage.jsp '; </script> ");
return;
}
if (op.equals ("del") && delid!=null) {
Statement stmt_channeldel=conn.createstatement ();
String sql= "Delete from hl_msg where id=" +delid;
int shan=stmt_channeldel.executeupdate (SQL);
if (shan>0) {
Out.print ("<script type=" Text/javascript "> Alert (") was successfully deleted! "); window.location.href= ' xq_manage.jsp '; </script> ");
}
Stmt_channeldel.close ();
return;
}
if (Op.equals ("look") && Delid!=null) {
Statement stmte=conn.createstatement (resultset.type_scroll_sensitive,resultset.concur_read_only);
String sqle= "Select * from hl_msg where id=" +delid;
ResultSet rse=stmte.executequery (Sqle);
if (Rse.next ()) {
%>
<table width= "80%" height= "156" border= "1" align= "center" bordercolor= "#d5d3d4" style= "margin-top:10px; Border-collapse:collapse "cellspacing=" 0 "cellpadding=" 0 ">
<tr>
<TD width= "align=" "Right" bgcolor= "#F3F3F3" > Demand Products:</td>
<TD width= "274 height=" align= "left" bgcolor= "#F3F3F3" class= "f-12-red" ><span >
<%=rse.getstring ("Ssname")%></span>-<span >
<%=rse.getstring ("Product")%>
</span></td>
</tr>
<tr>
<TD width= "align=" "right" > Demand:</td>
<TD height= "align=" "left" >
<%=rse.getstring ("Xq")%></td>
</tr>
<tr>
<TD width= "align=" "Right" bgcolor= "#F3F3F3" > Contact person:</td>
<TD height= "align=" "left" bgcolor= "#F3F3F3" >
<%=rse.getstring ("name")%></td>
</tr>
<tr>
<TD width= "align=" "Right" > Tel:</td>
<TD height= "align=" "left" >
<%=rse.getstring ("tel")%></td>
</tr>
<tr>
<TD width= "align=" "Right" bgcolor= "#F3F3F3" > Contact address:</td>
<TD height= "align=" "left" bgcolor= "#F3F3F3" >
<%=rse.getstring ("Address")%>
</label></td>
</tr>
<tr>
<TD width= "height=" align= "right" > Brief description:</td>
<TD align= "left" ><label>
<%=rse.getstring ("resumes")%>
</label></td>
</tr>
<tr>
<TD style= "padding-left:260px" height= "colspan=" "2" bgcolor= "#F3F3F3" >
<a href= "Javascript:history.go (-1);" > Return </a> <a href= "Xq_manage.jsp?id=<%=rse.getint (" ID ")%>&op=del" > Delete </a>
</td>
</tr>
</table>
<%
}
Rse.close ();
Stmte.close ();
return;
}
if (Op.equals ("add")) {
%>
<form name= "Form1" method= "Post" action= "" >
<table width= "100%" border= "0" align= "center" cellpadding= "1" cellspacing= "0" bgcolor= "#ECF5FF" >
<tr >
<TD width= "21%" height= "align=" "Center" bgcolor= "#ECF5FF" > website name </td>
<TD height= "colspan=" 2 "bgcolor=" #ECF5FF ">
<input type= "text" name= "name" size= "maxlength=" > </td>
</tr>
<tr>
<TD height= align= "center" bgcolor= "#ECF5FF" > website Introduction </td>
<TD height= "colspan=" 2 "bgcolor=" #ECF5FF ">
<input type= "text" name= "note" size= "maxlength=" > </td>
</tr>
<tr>
<TD height= align= "center" bgcolor= "#ECF5FF" > Connection address </td>
<TD height= "colspan=" 2 "bgcolor=" #ECF5FF ">
<input type= "text" name= "link" "size=" maxlength= "" value= "http://" > </td>
</tr>
<tr bgcolor= "#BBDAFF" >
<TD height= align= "center" bgcolor= "#ECF5FF" > Related pictures:</td>
<TD width= "22%" height= "bgcolor=" #ECF5FF "><input name=" img "type=" text "size=" > & Nbsp;</td>
<TD width= "57%" align= "left" valign= "center" bgcolor= "#ECF5FF" ><iframe style= "top:2px" name= "ad" src= ". /upload.htm "frameborder=0 scrolling=no width=" 100% "height=" > </iframe></td>
</tr>
<TR align= "center" bgcolor= "#A4B6D7" >
<TD height= "colspan=" 3 "bgcolor=" #ECF5FF ">
<input type= "hidden" name= "AddNew" Value= "true"/>
<input type= "Submit" name= "Submit" class= "Submission" value= "submitted" > <input type= "reset" name= "Submit2" class= "Submit" value= "reset" > </td>
</tr>
</table>
</form>
<%
return;
}
%>
<div align= "center" >
<table width= "border=" 0 "cellspacing=" 1 "bgcolor=" #CCCCCC ">
<tr height= bgcolor= "#FFFFFF" >
<TD width= > Contact person </td>
<TD width= > Tel </td>
<TD width= > Needs products </td>
<TD > Demand </td>
<TD width= > Management </td>
</tr>
<%
int pagesize=10; Number of articles displayed per page
int showpage=1; The page number displayed on the current page
int reccount=0; Total number of articles in resultset
int pagecount=0; Total pages after pagination
String topage = request.getparameter ("page");
Statement stmt3=conn.createstatement (resultset.type_scroll_sensitive,resultset.concur_read_only);
String sql3= "Select * from Hl_msg";
ResultSet rsf=stmt3.executequery (SQL3);
if (Rsf.next ()) {
Rsf.last ();
Reccount=rsf.getrow ();
Pagecount= (reccount%pagesize) ==0? ( reccount/pagesize):(reccount/pagesize) +1);
if (topage!=null)
Showpage=integer.parseint (ToPage);
Rsf.absolute ((showPage-1) *pagesize+1);
for (int i=1;i<=pagesize;i++) {
int ID = Rsf.getint ("id");
%>
<tr bgcolor= "#FFFFFF" onmouseover= "this.bgcolor= ' #f0f8ff '; onmouseout= ' this.bgcolor= ' #FFFFFF ';" >
<TD ><%=rsf.getstring ("name")%></td>
<TD ><%=rsf.getstring ("tel")%></td>
<TD ><%=rsf.getstring ("Product")%></td>
<TD ><%=rsf.getstring ("XQ")%></td>
<TD ><a href= "Xq_manage.jsp?id=<%=id%>&op=look" > View </a> | <a href= "Xq_manage.jsp?id=<%=id%>&op=del" onclick= "return Confirm" (' after deletion will not be restored, are you sure to delete it? ') ' > Delete </a></td>
</tr>
<%
if (! Rsf.next ())
Break
}
}
%>
</table>
<table width= "border=" "0" align= "center" cellpadding= "0" cellspacing= "0" >
<tr>
<td><div align= "center" ><br/>
<a class= ' f-12-black ' > Total <%=recCount%> Records <%= showpage% >/<%=pageCount%> page </a> <% if (showpage>1) {%><a class= ' f-12-black ' href= ' xq_manage.jsp?page=<%= showPage-1%> ' > Prev </a> <%} if (showpage<pagecount) {% > <a class= ' f-12-black ' href= ' xq_manage.jsp?page=<%= showpage+1 '%> ' > next page </a>  ; <%}%> <a class= ' f-12-black ' href= ' Xq_manage.jsp?page=<%=pagecount%> ' > last page </a> <a class= ' f-12-black ' > Goto <select name= ' sel_page ' onchange= ' javascript:location=this.options[ This.selectedindex].value; ' ><% for (int i=1;i<=pagecount;i++) { %> <option value= ' xq_manage.jsp?page=<%=i%> ' <% if (i==showpage) {%>selected <%}%>><%=i%></option><%}%></select> page </a>
</div></td>
</tr>
</table>
</div>
<%
Rsf.close ();
Stmt3.close ();
Conn.close ();
%>
</body>