Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Need to Login to next page if give Alert for Wrong Password

  1. #1
    Junior Member
    Join Date
    Aug 2022
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need to Login to next page if give Alert for Wrong Password

    I am very new to java, Here i want to know how to show login error if i type a wrong password that was not saved in my mysql database?

    System.out.println("Select count from users where pword='"+spword+"' and uname='"+suname+"');
    rsT = stmt.executeQuery("select count from users where pword='" + spword + "' and uname='"+suname+"'");
    if(rsT.next())
    {

    integer result = rsT.getint(1>);
    result= <jsp:forward page="Menu.jsp" />;
    }
    else
    {
    integer result = rsT.getint(0);
    result ="<center><h2>Invalid password</h2></center>";
    errFlag = true;
    }
    rsT.close();
    Last edited by maddyrafi; August 9th, 2022 at 11:59 PM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Need to display Alert for Wrong Password

    Where in the code do you want to display the error message?
    Would one of the methods of the JOptionPane class work?

    What is the %> notation for? It does not look like java source code.

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Aug 2022
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need to display Alert for Wrong Password

    Sir, I need to display the error alert message that if i entered wrong userid and password that not saved already in mysql earlier

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Need to display Alert for Wrong Password

    Would one of the methods of the JOptionPane class work?

    What is the <h2> notation for? It does not look like java source code. It looks like html.

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Need to display Alert for Wrong Password

    Also posted here: https://coderanch.com/t/753459/java/...ror-type-wrong


    Looks like JSP - moved to JSP section.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Aug 2022
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need to Login to next page if give Alert for Wrong Password

    I want to display if the code is correct. what wrong on my code

    rsT = stmt.executeQuery("select count from users where pword='" + spword + "' and uname='"+suname+"'");
    rsT.next();

    if(rsT.next())
    {

    int result= (rsT.getint(1) == 0);
    result = <jsp:forward page="Menu.jsp" />;
    errFlag = false;

    }
    else
    {
    result ="<center><h2>Invalid password</h2></center>";
    errFlag = true;
    }

Similar Threads

  1. Replies: 1
    Last Post: May 4th, 2014, 03:04 AM
  2. Replies: 1
    Last Post: May 4th, 2014, 03:04 AM
  3. Image display problem on JFrame...Whats wrong......need help?????'
    By suyog53 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 12th, 2012, 01:06 PM
  4. alert box in front end to display errors in backend
    By nischalinn in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: July 24th, 2012, 11:16 PM
  5. Replies: 0
    Last Post: April 3rd, 2012, 08:57 AM