public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // call DAO method to get the email and password HashMap<String,String> map=ViewDAO.getDetails(); //from the map you will get the email and password.then you need to set them in the attributes and get them in your jsp request.setAttribute("email", map.get("email")); request.setAttribute("password", map.get("password"));}
您的DAO方法应如下所示:
public static HashMap<String,String> getDetails(user u) { Connection con=ConnectionProvider.getCon(); String uname=u.getUname(); Map<String,String> map=new HashMap<>(); try { PreparedStatement ps=con.prepareStatement("select email,pass from S1.USER432 where name='"+uname+"'"); ResultSet rs = ps.executeQuery(); while (rs.next()) { String email = rs.getString("EMAIL"); String pass = rs.getString("PASS"); } map.put("email",email); map.put("password",pass); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }return map; }}
希望这会帮助你。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)