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


package myblog.servlet; 
 
import java.io.IOException; 
import java.util.ArrayList; 
 
import javax.servlet.ServletException; 
import javax.servlet.http.HttpServlet; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
 
import myblog.dao.UserInforDao; 
import myblog.entity.Users; 
 
public class UserInforServlet extends HttpServlet { 
 
	public void doPost(HttpServletRequest request, HttpServletResponse response) { 
		{ 
			String username = request.getSession().getAttribute("username") 
					.toString(); 
			UserInforDao user = new UserInforDao(); 
			ArrayList<Users> list = new ArrayList<Users>(); 
			if (username.equals("tourist")) { 
				list = user.userInfor("xiaoqiang"); 
			} else { 
				list = user.userInfor(username); 
			} 
			request.setAttribute("userinfor", list); 
			try { 
				request.getRequestDispatcher("userinfor.jsp").forward(request, 
						response); 
			} catch (ServletException e) { 
 
				e.printStackTrace(); 
			} catch (IOException e) { 
				e.printStackTrace(); 
			} 
 
		} 
 
	} 
	public void doGet(HttpServletRequest request, HttpServletResponse response){ 
		doPost(request,response); 
	} 
 
}