1

I am passing data through a bean, but whenever I use the passed data in a if function it never passes the first check. I will also post the result for just printing out the Get_Functions I am using.

The inputs I use are just admin and password.

JSP Code:

<jsp:useBean id="user" class="User.GetInfo" scope="session"/> 
<HTML>
<BODY>
<% if (user.getUsername() == "admin") {
    if (user.getPassword() == "password" ) {
        session.setAttribute( "LoggedIn", true );
        response.sendRedirect("AdminPage.jsp");

    } else {
        session.setAttribute( "LoginError", "Wrong password." ); 
        response.sendRedirect("AdminLogin.jsp");
    }
} else {

    session.setAttribute( "LoginError", "Wrong username." ); 
    response.sendRedirect("AdminLogin.jsp");
}
%>
</BODY>
</HTML>

Results for just printing out code:

You entered
 Name: admin
 Email: password
user40380
  • 76
  • 8
  • 1
    **don't** use `==` with `String`! –  Apr 24 '15 at 06:13
  • I tried it and it worked. And now that I found the problem I can confirm it is a duplicate. I do apologize it was not my intent. But thank you anyway. – user40380 Apr 24 '15 at 06:19

0 Answers0