0% found this document useful (0 votes)
64 views

Output

The document discusses user authentication using servlets and cookies. It describes creating a login page that takes a username and password and authenticates the user by comparing the input to stored credentials. If authenticated, the user is welcomed, else an error is shown. Cookies are also used to store and retrieve username and password between pages after login. Source code is provided for the HTML pages, XML configuration file, and Java servlets.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

Output

The document discusses user authentication using servlets and cookies. It describes creating a login page that takes a username and password and authenticates the user by comparing the input to stored credentials. If authenticated, the user is welcomed, else an error is shown. Cookies are also used to store and retrieve username and password between pages after login. Source code is provided for the HTML pages, XML configuration file, and Java servlets.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

1

*Output:

K. SAI SAMPATH 16131A05A0


2

Week-8
Module-1: User Authentication
Aim: Assume four users user1, user2, user3 and user4 having the
passwords pwd1, pwd2, pwd3 and pwd4 respectively.
To Write a servlet for doing the following:
1. Read the user id and passwords entered in the Login form and
authenticate with the values (user id and passwords) available in
the database.
2. If he is a valid user (i.e., user - name and password match) you
should welcome him by name(user-name) else you should display
“You are not an authenticated user”.
Description: Login page is created with fields Username and Password
with on submit redirect to other pages using URL pattern.
Source Code: login.html

K. SAI SAMPATH 16131A05A0


3

*Output:

*Output:

K. SAI SAMPATH 16131A05A0


4

Description: If the user submits the form without entering the fields an
error message is displayed along with the login form.
Source code: error4.html

Description: An error message “You are not an authenticated user” is


displayed if the user is not registered earlier.
Source Code: error5.html

K. SAI SAMPATH 16131A05A0


5

Description: An XML file is written which is used to specify what


servlets you want to use and what URLs you want to map them to.
Source Code: web.xml

K. SAI SAMPATH 16131A05A0


6

Description: When submit button is clicked java servlet is invoked use


the URL pattern given in the web.xml file.
Source Code: login.java

K. SAI SAMPATH 16131A05A0


7

*Output:

K. SAI SAMPATH 16131A05A0


8

Module-2: Cookies Example


Description: Login page is created which on submit displays entered
username and password by using corresponding servlet in which
cookies are added.
Source Code: login.html

Description: An XML file is written which is used to specify what


servlets you want to use and what URLs you want to map them to.
Source Code: web.xml

K. SAI SAMPATH 16131A05A0


9

*Output

K. SAI SAMPATH 16131A05A0


10

Description: This servlet is invoked when submit button is clicked on


the login page and cookies are added for username and password.
It displays the username and password and a button named view details
which on click another servlet page is invoked based on URL pattern.
Source Code: login.java

K. SAI SAMPATH 16131A05A0


11

*Output:

K. SAI SAMPATH 16131A05A0


12

Description: This servlet is invoked when view details button is


clicked and it retrieves the cookies information and is displayed.
Source Code: login1.html

K. SAI SAMPATH 16131A05A0

You might also like