I'm working with Java web (Filters), I want to redirect to a different JSP pages if user logged with some credentials. If I enter credentials for client, It logged fine, but if I want to logged as supervisor it redirects me to unauthorized login. I think this is for my if and else usage.
There is my code(do Filter):
try {
String usr = request.getParameter("usr");
String pswd = request.getParameter("password");
if(usr == null && pswd == null){
request.getRequestDispatcher("index.html").forward(request, response);
}
if(usr.equals("Client") & pswd.equals("123") ){
request.getRequestDispatcher("/Client.jsp").forward(request, response);
}else
request.getRequestDispatcher("/unautorized.jsp").forward(request, response);
if (usr.equals("Supervisor") & pswd.equals("123")){
request.getRequestDispatcher("/Supervisor.jsp").forward(request, response);
}else
request.getRequestDispatcher("/unautorized.jsp").forward(request, response);
if (usr.equals("Checker") & pswd.equals("123")){
request.getRequestDispatcher("/Checker.jsp").forward(request, response);
}else
request.getRequestDispatcher("/unautorized.jsp").forward(request, response);
chain.doFilter(request, response);
Why it stays at first else?
Aucun commentaire:
Enregistrer un commentaire