首页>代码>纯jsp+servlet+jdbc开发java web新闻发布系统>/sys/News/src/Servlet/deleteNews.java
package Servlet;


import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Dao.News;


public class deleteNews extends HttpServlet{
	public void init(ServletConfig config) throws ServletException{
		super.init(config);
	}
	 public void  doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
	      response.setContentType("text/html;charset=utf-8");
	      String id=request.getParameter("uid");
	  	try{
	  	int uid=(int)Integer.parseInt(id);
	  	News news=new News();
	  	news.getConn();
	  	if(news.findID(uid)){
	  		news.delete(uid);	  		
	  		response.sendRedirect("manage.jsp");
	  	}
	  	else{
	  		PrintWriter out=response.getWriter();
		     out.println("<html>");
			 out.println("<head>");
			 out.print("<style>a:link,a:visited,a:hover,a:active{text-decoration: none;color:53bcf8;align:center;}</style>");
			 out.print("</head>");
			 out.print("<body>");
			 out.print("<a href=deleteNews.jsp align=center>输入的新闻ID错误</a>");
			 out.println("</body></html>");
	  	}
	  	}
	  	catch (Exception e) {
			// TODO: handle exception
	  		response.sendRedirect("deleteNews.jsp");
		}
	   } 
	 public  void  doGet(HttpServletRequest request,HttpServletResponse response) 
     throws ServletException,IOException{
		 doPost(request,response);
	 }
	 

}
最近下载更多
qwqwx585160  LV2 2024年12月15日
wzd031105  LV2 2024年12月6日
lmj12345  LV2 2024年8月19日
cong58cong  LV8 2024年6月26日
bankroll  LV5 2024年6月13日
Waner111  LV1 2024年1月4日
asddwh  LV13 2023年12月26日
zj20020510  LV5 2023年9月24日
monolog  LV4 2023年4月18日
whq12138  LV3 2023年1月6日
最近浏览更多
qwqwx585160  LV2 2024年12月15日
traume 2024年12月11日
暂无贡献等级
lyh1989  LV34 2024年12月10日
wzd031105  LV2 2024年12月6日
ChanLain  LV2 2024年11月30日
yimaoermao  LV1 2024年11月28日
yyhrhv  LV8 2024年9月3日
asdfgh112 2024年7月4日
暂无贡献等级
时光海  LV2 2024年6月30日
sadselect  LV8 2024年6月28日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友