Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean checkLogin(String username, String password) {
- Query query = em.createNamedQuery("Account.find");
- query.setParameter("username", username);
- query.setParameter("password", password);
- Account acc = (Account) query.getSingleResult();
- if (acc != null) {
- return true;
- } else {
- return false;
- }
- }
- String username = request.getParameter("txtUsername");
- String password = request.getParameter("txtPassword");
- HttpSession session = request.getSession();
- session.setAttribute("USER", username);
- session.setAttribute("PASS", password);
- try {
- Context context = new InitialContext();
- Object obj = context.lookup("luyentap1JNDI");
- luyentapSessionBeanRemote poji = (luyentapSessionBeanRemote) obj;
- boolean result = poji.checkLogin(username, password);
- String url ="loginerror.html";
- if(result){
- boolean checkrole = poji.checkRoles(username);
- if(checkrole){
- url = "insert.jsp";
- } else{
- url = "roleerror.html";
- }
- }
- RequestDispatcher rd = request.getRequestDispatcher(url);
- rd.forward(request, response);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement