Hello everybody!
I trying to create authorisation algorithm, based on comparison between values, inputed from jsp-page and values, extracted from database. If values (login and password) are equal, going to page “/newsPage.jsp” must be implemented, else - going to page “/loginPage.jsp”.
But no matter what i inputted (equaled or not equaled values), going to page “/loginPage.jsp” is implemented.
I supposed, that problem is focused in query-expressions: for unknown reason string data don’t expressed from database properly.
Database contain only one row with id = 1.
Additionally: with starting Debug i received ClassNotFoundException: com.intellij.rt.debugger.agent.CaptureAgent.
String login = request.getParameter("login");
String password = request.getParameter("password");
int count = 1;
// int count2;
// Data extaction
Query etalonlogin2 = factoryClass.getSessionFactory().
openSession().createQuery("from Logindata where id=:counter").
setParameter("counter", count);
List<Logindata> logindataList = etalonlogin2.getResultList();
for (Logindata logindata : logindataList) {
etalonlogin = logindata.getLogin();
}
Query etalonpassword2 = factoryClass.getSessionFactory().
openSession().createQuery("from Logindata where id=:counter").
setParameter("counter", count);
List<Logindata> passworddataList = etalonpassword2.getResultList();
for (Logindata logindata : passworddataList) {
etalonpassword = logindata.getPassword();
}
//compare of data, which being extracted and inputed
if (etalonlogin.equals(login) & etalonpassword.equals(password)) {
if(response.isCommitted()) {
response.sendRedirect("/newsPage.jsp");
}
} else {
returnPage = "/loginPage.jsp";
getServletContext().getRequestDispatcher(returnPage).forward(request, response);
doGet(request,response);
}
I would be grateful for any help!