JSP article content management and deletion code

Source: Internet
Author: User

JSP article content management and deletion code
<BR/>
&nbsp; 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>
&LT;TD width= "align=" "Right" bgcolor= "#F3F3F3" > Demand Products:</td>
&LT;TD width= "274 height=" align= "left" bgcolor= "#F3F3F3" class= "f-12-red" ><span >&nbsp;
<%=rse.getstring ("Ssname")%></span>-<span >
<%=rse.getstring ("Product")%>
</span></td>
</tr>
<tr>
&LT;TD width= "align=" "right" > Demand:</td>
&LT;TD height= "align=" "left" >&nbsp;
<%=rse.getstring ("Xq")%></td>
</tr>
<tr>
&LT;TD width= "align=" "Right" bgcolor= "#F3F3F3" > Contact person:</td>
&LT;TD height= "align=" "left" bgcolor= "#F3F3F3" >&nbsp;
<%=rse.getstring ("name")%></td>
</tr>
<tr>
&LT;TD width= "align=" "Right" > Tel:</td>
&LT;TD height= "align=" "left" >&nbsp;
<%=rse.getstring ("tel")%></td>
</tr>
<tr>
&LT;TD width= "align=" "Right" bgcolor= "#F3F3F3" > Contact address:</td>
&LT;TD height= "align=" "left" bgcolor= "#F3F3F3" >&nbsp;
<%=rse.getstring ("Address")%>
</label></td>
</tr>
<tr>
&LT;TD width= "height=" align= "right" > Brief description:</td>
&LT;TD align= "left" ><label> &nbsp;&nbsp;
<%=rse.getstring ("resumes")%>
</label></td>
</tr>

<tr>
&LT;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 >
&LT;TD width= "21%" height= "align=" "Center" bgcolor= "#ECF5FF" > website name </td>
&LT;TD height= "colspan=" 2 "bgcolor=" #ECF5FF ">
<input type= "text" name= "name" size= "maxlength=" > </td>
</tr>
<tr>
&LT;TD height= align= "center" bgcolor= "#ECF5FF" > website Introduction </td>
&LT;TD height= "colspan=" 2 "bgcolor=" #ECF5FF ">
<input type= "text" name= "note" size= "maxlength=" > </td>
</tr>
<tr>
&LT;TD height= align= "center" bgcolor= "#ECF5FF" > Connection address </td>
&LT;TD height= "colspan=" 2 "bgcolor=" #ECF5FF ">
<input type= "text" name= "link" "size=" maxlength= "" value= "http://" > </td>
</tr>
<tr bgcolor= "#BBDAFF" >
&LT;TD height= align= "center" bgcolor= "#ECF5FF" > Related pictures:</td>
&LT;TD width= "22%" height= "bgcolor=" #ECF5FF "><input name=" img "type=" text "size=" >&nbsp;& Nbsp;</td>
&LT;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>

&LT;TR align= "center" bgcolor= "#A4B6D7" >
&LT;TD height= "colspan=" 3 "bgcolor=" #ECF5FF ">
<input type= "hidden" name= "AddNew" Value= "true"/>
<input type= "Submit" name= "Submit" class= "Submission" value= "submitted" >&nbsp;&nbsp;&nbsp; <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 ';" >
&LT;TD ><%=rsf.getstring ("name")%></td>
&LT;TD ><%=rsf.getstring ("tel")%></td>
&LT;TD ><%=rsf.getstring ("Product")%></td>
&LT;TD ><%=rsf.getstring ("XQ")%></td>
&LT;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 &nbsp;<%=recCount%>&nbsp; Records &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <%= showpage% >/<%=pageCount%> page </a>&nbsp;&nbsp;<% if (showpage>1) {%><a class= ' f-12-black ' href= ' xq_manage.jsp?page=<%= showPage-1%> ' > Prev </a>&nbsp;<%} if (showpage<pagecount) {% >&nbsp;<a class= ' f-12-black ' href= ' xq_manage.jsp?page=<%= showpage+1 '%> ' > next page </a>&nbsp ; <%}%>&nbsp;<a class= ' f-12-black ' href= ' Xq_manage.jsp?page=<%=pagecount%> ' > last page </a> &nbsp;<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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.