DeleteNews.java
上传用户:junmaots
上传日期:2022-07-09
资源大小:2450k
文件大小:1k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. /*
  2.  * Created on 2005-12-9
  3.  *
  4.  * TODO To change the template for this generated file go to
  5.  * Window - Preferences - Java - Code Style - Code Templates
  6.  */
  7. package com.mycompany.servlet;
  8. import java.io.IOException;
  9. import java.net.URLEncoder;
  10. import javax.servlet.ServletException;
  11. import javax.servlet.http.HttpServlet;
  12. import javax.servlet.http.HttpServletRequest;
  13. import javax.servlet.http.HttpServletResponse;
  14. import com.mycompany.news.dto.Column;
  15. import com.mycompany.news.dto.News;
  16. import com.mycompany.news.service.ColumnService;
  17. import com.mycompany.news.service.NewsService;
  18. /**
  19.  * @author Administrator
  20.  *
  21.  * TODO To change the template for this generated type comment go to
  22.  * Window - Preferences - Java - Code Style - Code Templates
  23.  */
  24. public class DeleteNews extends HttpServlet {
  25. protected void service(HttpServletRequest request, HttpServletResponse response)
  26. throws ServletException, IOException {
  27. String newsid = request.getParameter("newsid");
  28. News news = new News();
  29. news.setNewsId(Long.valueOf(newsid));
  30. NewsService ns = new NewsService();
  31. if(ns.deleteNews(news))
  32. response.sendRedirect(request.getContextPath()+"/opsucc.jsp?message="+URLEncoder.encode(ns.getMessage(),"GB2312"));
  33. else
  34. response.sendRedirect(request.getContextPath()+"/opfail.jsp?message="+URLEncoder.encode(ns.getMessage(),"GB2312"));
  35. }
  36. }