Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I am trying to display a logged in user full name after login but need some direction.I already validated the user against the database but it only returns the email from the login.How to i get information about the logged in user. I have three classes the LoginDAO,Session and managedbean,the loginDAO includes the query to fetch the required information from the database
- public class LoginDAO {
- public static boolean validate (String user,String password) throws SQLException{
- Connection con = null;
- PreparedStatement ps = null;
- try{
- con = DataConnect.getConnection();
- ps = con.prepareStatement("Select fname,lname,email, password from users where email = ? and password = MD5(?)");
- ps.setString(1, user);
- ps.setString(2, password);
- ResultSet rs = ps.executeQuery();
- if(rs.next()){
- rs.getString("fname");
- rs.getString("lname");
- return true;
- }
- }catch (SQLException ex){
- System.out.println("Login error -->" +
- ex.getMessage());
- return false;
- }finally{
- DataConnect.close(con);
- }
- return false;
- }
- private String fname;
- private String pwd;
- private String msg;
- private String user;
- public String getFname() {
- return fname;
- }
- public void setFname(String fname) {
- this.fname = fname;
- }
- public String getPwd() {
- return pwd;
- }
- public void setPwd(String pwd) {
- this.pwd = pwd;
- }
- public String getMsg() {
- return msg;
- }
- public void setMsg(String msg) {
- this.msg = msg;
- }
- public String getUser() {
- return user;
- }
- public void setUser(String user) {
- this.user = user;
- }
- return "login";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement