package com.action;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;

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

import com.bean.ComBean;
import com.util.Constant;

public class ComServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public ComServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request,response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType(Constant.CONTENTTYPE);
		request.setCharacterEncoding(Constant.CHARACTERENCODING);
		HttpSession session = request.getSession();
		ComBean cBean = new ComBean();
		String date=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
		String date2=new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
		String method = request.getParameter("method");
		 
		
		 if(method.equals("addlj")){ //  
			String mc = request.getParameter("mc");  
			String dz = request.getParameter("dz");   
				int flag=cBean.comUp("insert into lj(mc,dz  ) values('"+mc+"','"+dz+"'  ) ");
				if(flag == Constant.SUCCESS){ 
					request.setAttribute("message", "²Ù×÷³É¹¦£¡");
					request.getRequestDispatcher("admin/lj/index.jsp").forward(request, response); 
				}
				else { 
					request.setAttribute("message", "²Ù×÷ʧ°Ü£¡");
					request.getRequestDispatcher("admin/lj/index.jsp").forward(request, response);  
				}
			 
		} 
		else if(method.equals("uplj")){  // 
			String id = request.getParameter("id");  
			String mc = request.getParameter("mc");  
			String dz = request.getParameter("dz");   
			int flag=cBean.comUp("update lj set mc='"+mc+"',dz='"+dz+"' where id='"+id+"' ");
			if(flag == Constant.SUCCESS){ 
				request.setAttribute("message", "²Ù×÷³É¹¦£¡");
				request.getRequestDispatcher("admin/lj/index.jsp").forward(request, response);  
			}
			else { 
				request.setAttribute("message", "²Ù×÷ʧ°Ü£¡");
				request.getRequestDispatcher("admin/lj/index.jsp").forward(request, response);  
			}
		}
		else if(method.equals("dellj")){   
			String id = request.getParameter("id");   
			int flag=cBean.comUp("delete from lj where id='"+id+"' ");
			if(flag == Constant.SUCCESS){ 
				request.setAttribute("message", "²Ù×÷³É¹¦£¡");
				request.getRequestDispatcher("admin/lj/index.jsp").forward(request, response);  
			}
			else { 
				request.setAttribute("message", "²Ù×÷ʧ°Ü£¡");
				request.getRequestDispatcher("admin/lj/index.jsp").forward(request, response);  
			}
		} 
		else if(method.equals("delss")){   
			String id = request.getParameter("id");   
			int flag=cBean.comUp("delete from keyword where id='"+id+"' ");
			if(flag == Constant.SUCCESS){ 
				request.setAttribute("message", "²Ù×÷³É¹¦£¡");
				request.getRequestDispatcher("member/ss/index.jsp").forward(request, response);  
			}
			else { 
				request.setAttribute("message", "²Ù×÷ʧ°Ü£¡");
				request.getRequestDispatcher("member/ss/index.jsp").forward(request, response);  
			}
		} 
		 
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
最近下载更多
xk16675552250  LV33 1月8日
zhangjilu  LV18 1月1日
独家子弟  LV14 2023年8月23日
ziv5466123  LV7 2023年6月20日
addfs55  LV1 2023年3月6日
chen_jw  LV10 2023年2月20日
485415187  LV6 2022年11月20日
testuser1234567  LV24 2022年7月21日
403401  LV2 2022年6月24日
W 2022年4月7日
暂无贡献等级
最近浏览更多
WBelong  LV7 3月29日
可是不知道么  LV23 2月28日
廖业贵  LV18 2月23日
wangsheng818  LV4 2月22日
暂无贡献等级
钱小小  LV3 1月9日
xk16675552250  LV33 1月7日
iiiiiiixiiiiii  LV1 2023年12月28日
asddwh  LV12 2023年12月26日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友