Jsp

JSP Login Validation step by step

This tutorial will teach you how to make JSP Login Validation step by step.

Logging into the application

By default, the login credentials for the Admin are as follows:

Username: John

Password: 123

Form Design

index.jsp

<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
        <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
    </head>
    <body>
      <div class="container">
            <div class="row">  
            <div>
                <form action="login.jsp" method="POST" >
                    
                 <div class="form-group">
                     <h2>Login</h2>
                </div>    
     
                <div class="form-group">
                   <label>User Name</label>
                   <input type="text" name="uname" class="form-control"> 
                </div>
               
                 <div class="form-group">
                   <label>Password</label>
                     <input type="password" name="pass" class="form-control">
                </div>

                    
               <div class="form-group">        
                <button type="submit" class="btn btn-success">Submit</button>
               </div>    
                
              </form>  
           </div>       
           </div>   
        </div>
    </body>
</html>

login.jsp

if the user Insert incorrect Username or Password display the Error Message:
“Login Fail”
if the user Insert Username: Admin and Password: 123 display the Success Message:
“Login Success”
<%   
     String username = request.getParameter("uname");
     String pass = request.getParameter("pass");
     
     if(username.equals("John") && pass.equals("123"))
     {
         
         out.println("Login Success");
     }
     else
     {
           out.println("Login Fail");
     }
%>

 

admin

Recent Posts

Employee Working Hours Calculation System using C#.net

Initialize the employee number, Hourswork,and Hoursrate to calculate a grosswage use the following condition. if…

1 week ago

Java Payroll System Calculate Employee Overtime

Act as a Java developer to create a program that calculates the gross wage for…

2 weeks ago

Employee Working Hours Calculation System using Java

Initialize the employee number, Hourswork,and Hoursrate to calculate a grosswage use the following condition. if…

2 weeks ago

Laravel 11 School Management System

In this tutorial, we will teach you how to create a simple school management system…

3 weeks ago

How to Make Admin Panel Using React MUI

I have design the Admin Basic templete using React MUI Design Admin Dashboard and Login.Here…

1 month ago

Install Laravel Breeze for Authentication Using Laravel 11

In this tutorial ,i am to going teach the Laravel Breeze.Laravel Breeze provides a simple…

1 month ago