package com.wxpn.tutorial.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class for Servlet: DeleteNewsServlet
 */
public class DeleteNewsServlet extends javax.servlet.http.HttpServlet implements
		javax.servlet.Servlet {
	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public DeleteNewsServlet() {
		super();
	}

	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
	 *      HttpServletResponse response)
	 */
protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// 获取提交的用户名：
		String id = request.getParameter("id");
		NewsMgr mgr = new NewsMgr();
		
		try {
			mgr.delete(Integer.parseInt(id));
			request.getRequestDispatcher("BrowseServlet?url=admin_browse.jsp").forward(
					request, response);
		} catch (Throwable t) {
			getServletContext().log(t.getMessage());
		}
	}}