Assignment: Servlets
Assignment:
Servlets
Copyright © Virtusa Corporation
CONFIDENTIAL
Assignment: Servlets
Overview:
This assignment has eight exercises, ranging between 15-45 minutes. You are expected to complete the
course/ reference reading before attempting the exercise.
Learning Objective: This assignment has eight exercises. On completion of these you will be able to
implement a Servlet program.
Copyright © Virtusa Corporation
CONFIDENTIAL
Assignment: Servlets
Table of Content
[Link] Exercise Description Exception
1 Develop a web application This exercise is to develop a web After completion of this exercise,
for online shopping application using servlets. participate will be able to
understand how to fetch the data
from html and data base and display
it in Servlets
2 Develop a web application This exercise is to develop a web After completion of this exercise,
for online shopping application using servlets. participate will be able to maintain
the session across various pages
Copyright © Virtusa Corporation
CONFIDENTIAL
Assignment: Servlets
Servlets
Question: 1
Exercise Objective(s): understand how to fetch the data from html and data base and display it in Servlets
Exercise: Develop a web application where a customer can use this application by registering
themselves into the site. Once they have registered they can login to the site and start their
Shopping.
• Create an index page (/[Link]) which provides two options for the user.
• If the user is a registered user, he can login with his username and password.
• [Link] servlet will check whether the user is registered or not and displays the
success message if logged in.
• If not, redirect to the [Link] page with the error message.
• If the user is a registered user but the password entered is wrong, redirect to the index
page with the error message and provide a link for resetting the password.
• On clicking Reset Password link, the request is redirected to [Link].
• This page prompts the user to enter the email id and new password.
• If the entered email id doesn't match with registered user's email id, redirect to the index
page with error message.
• Else the password of the user is changed and redirect to the index page with success
[Link] he is not a registered user, he can register himself in [Link]
• [Link] servlet will check whether all the user details are entered according to
the constraints mentioned below.
Email should be valid [ for eg: xxx@[Link]].
Mobile Number should be of length 10 and should contain only integers.
The password must be converted into respective ASCII value and stored in the database[for eg:
AAB-656566].
All fields are mandatory fields.
Recommended duration: 180 minutes
Solution Guidance (if applicable): Use scriptlet.
Copyright © Virtusa Corporation
CONFIDENTIAL
Assignment: Servlets
Question: 2
Exercise Objective(s): Session Tracking
Exercise: Write a servlet program to get the student details in three different pages for which background
colour should be choosen in Index page.
You are very much interested in publishing current events and fun activities in and around
your city through weekly magazine to your college friends. There was good response from your
readers and the same magazine was passed to their friends and went viral around students
community.
You wanted to use this opportunity to expand your network and collect all the interested
students information in your personal website. You wanted to provide the facility that users can
select different background colors during the registration. Now the steps to be followed are,
Steps:
The registration page spans to three different pages,
1. Personal information
1. Name
2. Age
3. Gender
2. Curriculum
1. 10th Mark
2. 12th Mark
3. UG Mark
3. Contact Information
1. E-Mail address
2. Phone number
In the first page user have to select a color, that color must be the background color for all the
remaining pages. This color information is stored in session so that we can use this in multiple
pages.
Copyright © Virtusa Corporation
CONFIDENTIAL
Assignment: Servlets
Design Constraints :
1. 1st Page
1. Color select box should have the name "color"
2. Add these colour values to the dropdown Pink,Green,Brown,Chocolate,Cyan
2. 2nd Page
1. Text fields names are "name","age"
2. Select box name "gender" with options "Male,Female"
3. 3rd Page
1. Text field name should be "tenthMark"
2. Text field name should be "twelfthMark"
3. Text field name should be "ugMark"
4. 4th page
1. Text field name should be "mail"
2. Text field name should be "phone"
5. 5th page display all the information
6. From 2nd page to 5th page, all pages should have the selected color displayed as their
background. Pages must not contain any hidden fields
7. Use buttons of type 'submit'
Flow:
Recommended duration: 30 minutes
Solution Guidance (if applicable): Use scriptlet.
Guidance (if applicable): Use Session Tracking Techniques.
Copyright © Virtusa Corporation
CONFIDENTIAL