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


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.SaveModifyUserInforDao; 
 
public class SaveModifyUserInforServlet extends HttpServlet { 
	public void doPost(HttpServletRequest request, HttpServletResponse response) { 
		String username = request.getSession().getAttribute("username") 
				.toString(); 
		String password = request.getParameter("pwd1"); 
		String question = request.getParameter("password_question"); 
		String answer = request.getParameter("password_answer").trim(); 
		String email = request.getParameter("e_mail").trim(); 
		String sex = request.getParameter("sex"); 
		String content = request.getParameter("introduce").trim(); 
		SaveModifyUserInforDao infor = new SaveModifyUserInforDao(); 
 
		int num = infor.UpdateUserInfor(username, password, question, answer, 
				email, sex, content); 
		if (num == 1) { 
			request.setAttribute("regmsg", "更新成功!"); 
		} else { 
			request.setAttribute("regmsg", "更新失败!"); 
		} 
 
		try { 
			request.getRequestDispatcher("usermodify.jsp").forward(request, 
					response); 
		} catch (ServletException e) { 
			e.printStackTrace(); 
		} catch (IOException e) { 
			e.printStackTrace(); 
		} 
	} 
 
}