Login page

Posted on 2004-11-27
Last Modified: 2010-04-01
how do i create a login page such that if username and password is wrong an error message is shown on page. if correct, another page is opened. I'm using form action="xxx.jsp" which opens the other page even if password is wrong.
Question by:VbMonk
    LVL 8

    Accepted Solution

    String usr="UserName";
    String pwd="Password";
    if(usr == pwd)
     out.print("same page");

     out.print("next page");

    follow some of the links :
    LVL 16

    Assisted Solution

    Hi VbMonk,

    To display MessageBox telling error message can be achieved using JavaScript. Let me give you some sample.

    <script language="javascript">
    function check()
        var form1 = document.myForm;
        if (form1["username"].value != form1["password"].value)
          alert('Username and password are wrong. They should be the same');
          location.href = "look.jsp";
    <form name="myForm">
    User name : <input type="text" name="username">
    Password : <input type="text" name="password">
    <input type="button" value="Submit" onclick="check()">


    Hence, if you type the username to be different with the password, you will get error message. If you type in the same username and password, you will be directed to the look.jsp.

    I hope this is what you want.

    LVL 16

    Assisted Solution


    >if correct, another page is opened.

    What happen if someone knows the private page's URL and accesses it directly from address bar without through the login page?
    Have you planned for that hole?

    In case of *you concern about that hole*, I recommend you to join with HTML, Servlet, Filter and Session.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Suggested Solutions

    Title # Comments Views Activity
    html form inside div 3 81
    stateless EJB with glassfish 2 65
    parse example 13 81
    'exit' is not valid keyword in java 14 122
    At the beginning of the year, the IT world was taken hostage by the shareholders of LogMeIn. Their free product, which had been free for ten years, all of the sudden became a "pay" product. Now, I am the first person who will say that software maker…
    If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now