www.webdeveloper.com
Results 1 to 4 of 4

Thread: if statement

  1. #1
    Join Date
    Sep 2011
    Posts
    12

    if statement

    why isn't the if statement working. It goes else part even if the username and password is in there.

    String vusername = request.getParameter("username");
    String vpassword = request.getParameter("password");

    if((vusername != null) && (vusername.equals(""))) {
    response.sendRedirect("http://localhost:8080/myHW3/CatalogServlet");
    } else {
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Login</title>");
    out.println("</head>");
    out.println("<BODY BGCOLOR=357EC7>");
    out.println("<form method=POST>");
    out.println("Invalid username/password");
    out.println("<p><A style=color:black HREF=RegistrationServlet>Click here to return to Login Page</A></p>");
    out.println("</form>");
    out.println("</BODY></HTML>");

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,123
    I think u want to say when !vusername.equals("")
    instead, which would mean you are checking for
    when user is not null and user is not empty
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  3. #3
    Join Date
    Oct 2011
    Posts
    40
    For what purpose you are using - vusername.equals((""))??
    Try if block without using vusername.equals((""))

  4. #4
    Join Date
    Sep 2011
    Posts
    12
    it was actually a syntax error in the HTML...thanks!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles