Question

Java Servlet Program that represents an authentication platform where user will authenticate their username, passwordand usercode....

Java Servlet Program that represents an authentication platform where user will authenticate their username, passwordand usercode. After successful authentication, a message will be printed on the screen. All the wrong use of credentials will result in error that you will handle and there will also be a message displayed on the screen.

Following are minimum guidelines:

1. The front end should have a background color and a heading like “User authentication System”.
2. It should have a text field with label ‘username’ where user will enter username, a text field with label ‘password’ where user will enter password, a text field with label usercode where user will enter a usercode and a submit button with label Submit.
3. Initially all text fields will be blank and no color. User enters a wrong username, a message will be printed on the front end “You entered wrong username, please try again”, and the color of the ‘username’ text field will turn red. When a correct username is entered, the color of text field will turn green. This behavior should persist for all text fields.
4. A successful authentication should be followed by a message on the screen stating that then authentication is successful.
5. User doesn’t input any value on any of the text fields and clicks the submit button will result as an error and you should handle it. On the front end a message should display “Please enter a username
6. All incorrect entry will result in an error and a message on the front end “You entered wrong …….., please try again”.
8. Database info:

A. Create a database “authDataBase
B. Create a table ‘accountinfo” in that database with the following:

userIDusernamepasswordusercode
100 janediamjane777
101 johndjohniam888

Homework Answers

Answer #1

Hi,

index.html

<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8"/>
<title>User Authetication</title>
</head>
<body bgcolor="#acbbdd" style="font-size: 65px;color:#fff;text-align: center;"><p></p>
   <div><b>User Authetication System</b></div>
   <div>
       <form method="/index.jsp" action="get">                                               <!--send form in get method to index.jsp -->
           <table style="font-size: 29px;" align="center">
           <tr>
               <td>Name:</td>
               <td><input type="text" name="username" placeholder="Enter your username"></td>          
           </tr>
           <tr>
               <td>Password:</td>
               <td><input type="Password" name="Password" placeholder="Enter your password"></td>
           </tr>
           <tr><td><input type="Submit"></td></tr>
           </table>                  
       </form>      
   </div>
</body>
</html>

index.jsp

<%@ page import = "java.sql.*" %>                               <%--importing java.sql.* --%>
<%@ page import = "javax.sql.*" %>                               <%--importing javax.sql. --%>
<%-- getting the values from request object by getParameter function and storing the values in user and pass,
Class.forName to call the jdbc driver for code database connection DriverManager.getConnection to settle the connection and passing three arguments namely, url(to which point to be hit from where the data to be fetched in request object the, simply the url), username (mine is root), then password(), authDataBase is the name of the database. st a Statement object which consist of all query to be ran in my sql and .executeQuery will run the query and storing the data in ResultSet object. executing the query as "select * from accountinfo where userId="+user+"and password ="+pass" will allow to fetch only that dataset which matches with the passed value i.e. username and password, and if valus are correct then there muct be something returns to resultSet object and .next() will checkk this if it contains that implies the data is correct and it is valid user credential otherwise not. --%>
<%
   String user = request.getParameter("username");              
   String pass = request.getParameter("Password");
   Class.forName("com.mysql.jdbc.Driver");
   java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/authDataBase","root","");
   Statement st = con.createStatement();
   ResultSet resultSet = st.executrQuery("select * from accountinfo where userId="+user+"and password ="+pass);
   if(resultSet.next()){
       out.print("Welcome"+user);      
   }else{
       out.print("You entered wrong ..............,,,,,Please try again.");
   }
%>

query.sql

create database authDataBase;

use authDataBase;

create table accountinfo(userID int,username varchar(255),password varchar(255),usercode int);

insert into accountinfo values(100,'janed','iamjane',777);

insert into accountinfo values(101,'johnd','johniam',888);

select * from accountinfo;

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
For this assignment, create an html page that has a login form. The form should have...
For this assignment, create an html page that has a login form. The form should have 3 input elements -- 1. This should have a type text for the user to enter UserName 2. This should have a type password (like text except cannot see the text that is typed in), for the user to enter password. 3. Submit button (type submit, as we did in class on 2/6). The form method should be set to POST and the action...
Using Java: implement a program with the following features. Thanks Produce a menu for the user...
Using Java: implement a program with the following features. Thanks Produce a menu for the user with 3 choices. Add a new user Attempt login See all users If the user chooses #1, prompt them for a username (a string). Then a password (a string). Using SHA-2 hash the password they gave you, and store the resulting username and hashed password in a datastructure of your choice. (It can be 2 arrays, one for usernames, one for hashed passwords). If...
Please Use JavaScript and P5 3) Password Protected Create an application with two input fields and...
Please Use JavaScript and P5 3) Password Protected Create an application with two input fields and one button. When the button is clicked, verify the user has written these (exact) strings in the first and second field: First field should be "Username" Second field should be "Password" If the two fields match, update a DIV on the page with the text "Success" or else "Wrong information". For this assignment: use only one if statement to to the check. Remember you'll...
Data Encryption (Strings and Bitwise Operators) Write a C program that uses bitwise operators (e.g. bitwise...
Data Encryption (Strings and Bitwise Operators) Write a C program that uses bitwise operators (e.g. bitwise XOR) to encrypt/decrypt a message. The program will prompt the user to select one of the following menu options: 1. Enter and encrypt a message 2. View encrypted message 3. Decrypt and view the message (NOTE: password protected) 4. Exit If the user selects option 1, he/she will be prompted to enter a message (a string up to 50 characters long). The program will...
<?php    if(isset($_GET['submit'])){ //sanitize the input        /* Check the error from the input: if...
<?php    if(isset($_GET['submit'])){ //sanitize the input        /* Check the error from the input: if input from user is empty -> get an error string variable if input is not empty -> use preg_match() to match the pattern $pattern = "/^[1-9][0-9]{2}(\.|\-)[0-9]{3}(\.|\-)[0-9]{4}$/"; -> if it's a matched, get a success string variable */           } ?> <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link...
Python: Simple Banking Application Project Solution: • Input file: The program starts with reading in all...
Python: Simple Banking Application Project Solution: • Input file: The program starts with reading in all user information from a given input file. The input file contains information of a user in following order: username, first name, last name, password, account number and account balance. Information is separated with ‘|’. o username is a unique information, so no two users will have same username. Sample input file: Username eaglebank has password 123456, account number of BB12 and balance of $1000....
Create an application that will give valuable advice to future students from someone (you!) who is...
Create an application that will give valuable advice to future students from someone (you!) who is close to graduation. However, only end-users who have their credentials validated against the database (which uses encrypted passwords) are allowed entry. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- advice_ddl.sql CREATE DATABASE advice; USE advice; CREATE TABLE users ( id int primary key auto_increment, username varchar(255), password varchar(255) ); -- insert a row into the users table: -- username = foo -- password = bar INSERT INTO users (username, password) VALUES...
In UNIX .Write a bash script that takes a list of usernames as its command line...
In UNIX .Write a bash script that takes a list of usernames as its command line arguments and displays on the screen, for each user name, a message of the form Number of times that logged into this machine is where is to be replaced by the number of recors that the last command output that match exactly. For example, if i enter command logincount mark it should output something like number of times that sweiss logged into this machin...
In the previous assessment, you used a static set of named variables to store the data...
In the previous assessment, you used a static set of named variables to store the data that was entered in a form to be output in a message. For this assessment, you will use the invitation.html file that you modified in the previous assessment to create a more effective process for entering information and creating invitations for volunteers. Rather than having to enter each volunteer and create an invitation one at a time, you will create a script that will...
4) Write a Java program using Conditions: Write a program where it will ask user to...
4) Write a Java program using Conditions: Write a program where it will ask user to enter a number and after that it will give you answer how many digits that number has. Steps: 1) Create Scanner object and prompt user to enter the number and declare variable integer for input 2) Use if else condition with && condition where you will specify the digits of numbers by writing yourself the digit number that should display: Example(num<100 && num>=1), and...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT