Good night to you all! I'm doing a login using JSP pages in Java. I have to set the parameters of my method (login) that has two intern parameters (String email, String password). I'm getting the input values and I have to see if they are the same. (Sorry for my english, is not too good). My code is:
SERVLET
Studente student = new Studente(); boolean resp = false; if(request.getParameter("email").equals(student.getE_mail()) && request.getParameter("pass").equals(student.getPassword_())){ resp=true; System.out.print(student.getE_mail()); System.out.print(resp); } else{ resp=false; System.out.print(resp); }
LOGIN CLASS METHOD (the class has 2 constructors, the first is empty and the second is full)
public static boolean login(String e_mail, String password_){ boolean ret=true; Session session1 = HibernateUtil.openSession(); Transaction tx = null; try { tx = session1.getTransaction(); tx.begin(); session1.createQuery("SELECT e_mail, password_ from Studente where e_mail='"+e_mail+"' and password_='"+password_+"'").uniqueResult(); tx.commit(); } catch (Exception e) { ret = false; if (tx != null) { tx.rollback(); } e.printStackTrace(); } finally { session1.close(); } return ret;
}
https://stackoverflow.com/questions/66084174/how-to-set-parameters-for-a-java-server-page-doing-a-login-help-me-please February 07, 2021 at 11:05AM
没有评论:
发表评论