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

Jsp/Servlet

开发平台:

Java

  1. /*
  2.  * Created on 2005-12-10
  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 java.text.ParseException;
  11. import java.text.SimpleDateFormat;
  12. import java.util.Date;
  13. import javax.servlet.ServletConfig;
  14. import javax.servlet.ServletException;
  15. import javax.servlet.http.HttpServlet;
  16. import javax.servlet.http.HttpServletRequest;
  17. import javax.servlet.http.HttpServletResponse;
  18. import com.jspsmart.upload.Request;
  19. import com.jspsmart.upload.SmartUpload;
  20. import com.jspsmart.upload.SmartUploadException;
  21. import com.mycompany.news.dto.News;
  22. import com.mycompany.news.service.NewsService;
  23. /**
  24.  * @author Administrator
  25.  *
  26.  * TODO To change the template for this generated type comment go to
  27.  * Window - Preferences - Java - Code Style - Code Templates
  28.  */
  29. public class CancelRecommendNews extends HttpServlet {
  30. private ServletConfig config;
  31. public void init(ServletConfig arg0) throws ServletException {
  32. config = arg0;
  33. }
  34. protected void service(HttpServletRequest request, HttpServletResponse response)
  35. throws ServletException, IOException {
  36. NewsService nservice = new NewsService();
  37. long newsid =Long.parseLong(request.getParameter("newsid"));
  38. boolean result;
  39. try {
  40. result = nservice.cancelRecommendNews(newsid);
  41. if(result)
  42. response.sendRedirect(request.getContextPath()+"/opsucc.jsp?message="+URLEncoder.encode(nservice.getMessage(),"GB2312"));
  43. else
  44. response.sendRedirect(request.getContextPath()+"/opfail.jsp?message="+URLEncoder.encode(nservice.getMessage(),"GB2312"));
  45. } catch (Exception e) {
  46. // TODO Auto-generated catch block
  47. e.printStackTrace();
  48. response.sendRedirect(request.getContextPath()+"/opfail.jsp?message="+e.getMessage());
  49. }
  50. }
  51. }