www.pudn.com > Jsp-Blog.rar > AddReviewServlet.java, change:2010-05-25,size:1191b


package myblog.servlet; 
 
import java.io.IOException; 
 
import javax.servlet.ServletException; 
import javax.servlet.http.HttpServlet; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
 
import myblog.dao.AddReviewDao; 
 
public class AddReviewServlet extends HttpServlet { 
 
	public void doPost(HttpServletRequest request, HttpServletResponse response) { 
 
		String logid = request.getParameter("logid"); 
		String reviewname = request.getParameter("reviewname"); 
		String reviewcontent = request.getParameter("reviewcontent"); 
		AddReviewDao addReview = new AddReviewDao(); 
		int num = addReview.addReview(reviewcontent, reviewname, logid); 
		if (num == 1) { 
			request.setAttribute("reviewmsg", "评论成功!"); 
		} else { 
			request.setAttribute("reviewmsg", "评论失败!"); 
		} 
		try { 
			request.getRequestDispatcher("reviewSucess.jsp") 
					.forward(request, response); 
		} catch (ServletException e) { 
 
			e.printStackTrace(); 
		} catch (IOException e) { 
 
			e.printStackTrace(); 
		} 
	} 
 
	public void doGet(HttpServletRequest request, HttpServletResponse response) { 
		doPost(request, response); 
	} 
 
}