DI-322L - Web Techechnologies Lab Manual
DI-322L - Web Techechnologies Lab Manual
Web T ec h n ol og i es Lab
Lab 01 Marks 00
Instructions
Work on this quiz/lab individually.
You are NOT allowed to use internet, mobile phone.
You are NOT allowed to borrow anything from your peer student.
Task 1 [00]
Take any two integer numbers and print their sum in the following format:
Example: If numbers are 4 and 5, you program should display :
Sum of 4 and 5 is 9
Hint:
Integer variable declaration is the same as you used in C++.
You can use ‘+’ operator for string concatenation.
Task 2 [00]
Write a program that prints a table of any integer number. For instance, the table of 3 is given in the following.
3x1=3
3x2=6
.
.
3 x 10 = 30
Hint:
The syntax of loop is the same as you used in C++.
You can use ‘+’ operator for string concatenation.
Task 3 [00]
Write a program that prints the following information about yourself.
Roll No.
Name
Degree
Semester
CGPA
Address
City
BEST OF LUCK
Web T ec h n ol og i es Lab
Lab 02 Marks 100
Instructions
Work on this lab individually.
You are NOT allowed to use internet, mobile phone.
You are NOT allowed to borrow anything from your peer student.
Task 1 [25]
Write a program that will take integer input from the user and print a right angle pattern based on the input number.
Example: If n=5 then the output should look like:
1
12
123
1234
12345
Your program must ask in the end that whether the user wants to continue (y/n)? If he/she enters n, exit the program;
again get an input and display the pattern accordingly otherwise.
Task 2 [25]
Write a program that asks the user to enter two integers, and prints their sum, product, difference and quotient
(division).
Task 3 [25]
Write a program that takes a positive integer n as input from user and prints true if the number is a factorial number.
A factorial number is a number that is resulted from factorial of some number.
Example: 120 is a factorial number because 5! = 120.
Task 4 [25]
Write a java program which accepts n numbers from the command line and display the largest and 2nd largest number
of all the numbers.
Example: Input: 1 2 3 4 5 6 7 8 9
Output: 9 8
Hint: For integer conversion you can use the following statement:
int number = Integer.parseInt(“100”);
BEST OF LUCK
Web T ec h n ol og i es Lab
Lab 03 Marks 100
Instructions
Work on this quiz/lab individually.
You are NOT allowed to use internet, mobile phone.
You are NOT allowed to borrow anything from your peer student.
Task [100]
A company pays its employees on a weekly basis. The employees are of four types: Salaried employees are paid a fixed
weekly salary regardless of the number of hours worked, hourly employees are paid by the hour and receive overtime
pay for all hours worked in excess of 40 hours, commission employees are paid a percentage of their sales and salaried-
commission employees receive a base salary plus a percentage of their sales. For the current pay period, the company
has decided to reward salaried-commission employees by adding 10% to their base salaries. The company wants to
implement a Java application that performs its payroll calculations polymorphically.
Create a class Employee to represent the general concept of an employee. Each employee has a first name, a last name
and a social security number. Declare them private in superclass Employee and provide their public getter/setter
functions. In addition class Employee provides methods earnings() and toString(). Method toString() in class Employee
returns a string containing the first name, last name and social security number of the employee.
The classes that extend Employee are SalariedEmployee, CommissionEmployee and HourlyEmployee. Class
BasePlusCommissionEmployee which extends CommissionEmployee represents the last employee type. Each subclass
overrides earnings() and toString() with an appropriate implementation.
The desired list of attributes and functions in each of the class is depicted in the following table.
All the data-members shall be private with appropriate public getter/setter functions.
Employee class must have three arguments constructor to initiate the Employee’s attributes.
Each of the subclass shall make a super() call to initialize/set the basic information of an employee. The rest of
the data-members can be initialized in their respective classes.
Write a Driver class and maintain an array of ten Employees. Creates two objects of each of the class: Employee,
SalariedEmployee, HourlyEmployee, CommissionEmployee and BasePlusCommissionEmployee, and save them in
array. Write a loop, and iterates through the array of Employee, polymorphically. While processing the objects
polymorphically, the program shall increase the base salary of each BasePlusCommissionEmployee by 10% (this, of
course, requires determining the object's type at execution time). Finally, the program polymorphically determines and
outputs the type of each object in the Employee array using method calls of earnings() and toString().
BEST OF LUCK
Web T ec h n ol og i es Lab
Lab 04 Marks 100
Instructions
Work on this quiz/lab individually.
You are NOT allowed to use internet, mobile phone.
You are NOT allowed to borrow anything from your peer student.
Task [100]
Create a small application for a car showroom. Include the following classes in the package named as showroom.
Write a class Sedan with data members int id, string model, string color, string
brand, string price. Provide a full parameterized constructer. Also write accessors,
mutators for all data members.
Write a class SUV with similar operations as for the above class.
Write a Driver class with array of Vehicle, and provide a menu to customer having options to see sedan or SUV
information. On selecting option relevant data should be shown to customer. The Driver class must reside in a
separate package named as runner.
Instructions:
BEST OF LUCK
Web T ec h n ol og i es Lab
Lab 05 Marks 100
Instructions
Work on this quiz/lab individually.
You are NOT allowed to use internet, mobile phone.
You are NOT allowed to borrow anything from your peer student.
Task [100]
Create a class PalindromeNumber and implement a function bool isPalindrome(String s) which will check
whether the given string is a palindrome or not. If the given input is a number and palindrome, the method will return
true.
The method should throw an Exception notANumberException if the given string is not a number and a
notAPalindromeException exception if it is not a Palindrome, to its caller method. Your program must handle the
thrown exception by displaying an appropriate message to the user.
Create a Driver class, take input from user in main() and show the functionality of doing exception handling.
Example:
Instructions:
A Palindrome is a word, phrase, or sequence that reads the same backward as forward e.g., Level, Racecar, 676
You can override String toString()method in your respective class to print the description of the exception.
BEST OF LUCK
Web T ec h n ol og i es Lab
Lab 06 Marks 100
Instructions
Work on this quiz/lab individually.
You are NOT allowed to use internet, mobile phone.
You are NOT allowed to borrow anything from your peer student.
Task [100]
Create a small application to save the records of employees in an organization. Create a class Employee with attributes
int id, string name, static double salary, string rank and implement the following functions:
to read/load data from csv file; create objects and add it to a collection.
to add a new object into collection.
to write all the objects from collection to a txt file.
to remove an object from collection based on id.
Create a Driver class, and show the functionality of your program using a switch menu.
Instructions:
You can read data line by line from a csv file, and then split the data based on comma.
BEST OF LUCK
Web T ec h n ol og i es Lab
Lab 07 Marks 100
Instructions
Work on this quiz/lab individually.
You are NOT allowed to use internet, mobile phone.
You are NOT allowed to borrow anything from your peer student.
Task [100]
Create a class Employee with three attributes: String name, String department, and double salary. Provide
its constructor, getter/setter, and printing functions.
Create a class MyThread that is extended by java.lang.Thread. It has one data member String func (its value can be
write or read). Implement run() function which generate a call to FileHanlder’s function based on the value of func.
In main(), show a menu to user if he/she wants to write, read or exit, and create a new thread to fulfil each of the
request.
Instructions:
You must need to read/write data object by object.
Use of any collection object is optional.
Similar to our code examples in lecture, you may create the following instance variables in your MyThread class.
Thread t; //holds the thread information
FileHandler obj; //holds the FileHandler class object
String func; // holds the message read/write
Initialize these variables using the constructor of MyThread class.
In run(), simply generate a call to the respective function based on the value of String func.
BEST OF LUCK
Web T ec h n ol og i es Lab
Lab 08 Marks 00
Instructions
Work on this quiz/lab individually.
You are NOT allowed to use internet, mobile phone.
You are NOT allowed to borrow anything from your peer student.
Task [00]
Create your resume in tabular format using HTML. It must contains the following sections:
Personal Information
Academics
Experience
Skills
References
Instructions:
You may use any appropriate editor.
Add your picture in the resume.
BEST OF LUCK
Web T ec h n ol og i es Lab
Lab 09 Marks 100
Instructions
Work on this quiz/lab individually.
You are NOT allowed to use internet, mobile phone.
You are NOT allowed to borrow anything from your peer student.
Task [100]
Create an HTML form with two input fields, one output field and four buttons labelled as Sum, Subtraction, Multiply, and Divide,
as depicted in the following. Whenever a button is clicked, your program shall get the user provided values from input fields,
compute and display the appropriate result in output field.
First Number:
Second Number:
Result:
Your program shall display the Browser Version and Name at the loading time of page.
Instructions:
All input and output fields shall be type of text.
For each of the button, you must have to handle onclick event.
All the inputs fields are mandatory. Display appropriate error message(s) if user presses the button without entering the data
in the respective input field(s).
The values of both fields must not be the same; display appropriate error message otherwise.
In case of subtraction, the value of first-input-field must be greater than the second-input-field; display appropriate error
message otherwise.
For number conversion, you can use one of the following methods:
o Number() // Number("23") => returns 23
o parseInt()
o parseFloat()
BEST OF LUCK
Web T ec h n ol og i es Lab
Lab 10 Marks 100
Instructions
Work on this quiz/lab individually.
You are NOT allowed to use internet, mobile phone.
You are NOT allowed to borrow anything from your peer student.
What you have to do
Program the following tasks. The name of your files will be according to the task given in this lab.
Task [100]
Create a Servlet application that allows a user to perform CRUD (Create, Read, Update and Delete) operations on a collection of
books. The application should use the GET method for reading, and the POST method for creating, updating and deleting books.
Step 1: Create a new Java web project and add a new Servlet class.
Step 2: In the servlet class, create a collection of books as an instance variable. The sample code is described in the following
ArrayList<Book> AL;
Step 3: In doGet() method, add code to handle the reading of books from the collection and display them in HTML tabular format.
The table should be generated dynamically by reading the books from the collection and adding them as rows to the table.
Step 4: In doPost() method, add code to handle the creation, updation and deletion of books in the collection. The servlet class
should handle the following actions:
Creation: A user should be able to add a new book to the collection by submitting a form that includes fields for the book's
title, author and ISBN.
Updating: A user should be able to update the details of an existing book by submitting a form that includes fields for the
book's title, author and ISBN.
Deletion: A user should be able to delete a book from the collection by submitting a form with a field for the book's ISBN.
Step 5: Create web.xml file and map the servlet class to a specific URL pattern, for example, "/books"
Step 6: Create HTML forms for adding, updating and deleting books. The forms should use the GET method and have the action set
to the URL pattern mapped to the servlet in web.xml
Step 7: Test the application by adding, updating and deleting books, and ensure that the changes are reflected in the table.
Instructions:
Use request.getParameter("field-name") to get form-field values.
In doPost() method, you can have if-else if conditions to perform the specific task (i.e., creation, updating and
deletion).
You are not allowed to use any IDE in this lab.
BEST OF LUCK
Regular Class: The following task must be implemented with proper Session handling.
Special Section: The task may be implemented using the concepts of Request Dispatching.
Task [100]
Step 1:
Implement a web-based Book Management System. This system has two type of users: Admin and Typical User.
Admin can add or delete any book
Typical User can only search his/her desired book.
You don’t need to provide the signup functionality. Just manually add a few records in database, manually.
Step 2:
On the successful Login,
an Admin can add/delete a book information into the system. Provide appropriate pages.
a Typical User should be redirected to index page where you need to display a welcome message to user (Welcome,
USERNAME).
A Typical User can perform the following tasks:
View All Books: Redirects to the page that shows all books added into the system.
Search Book: Provides the functionality to search any specific book.
Instructions:
You must need to start the session when user is logged-in.
For JDBC, you can directly copy the code from your previous lab/lecture.
To save the book information, the list of attribute is: bookID (int), bookTitle(string), author(string),
ISSN(string)
BEST OF LUCK
Web T ec h n ol og i es Lab
Lab 13 Marks 100
Instructions
Work on this quiz/lab individually.
You are NOT allowed to use internet, mobile phone.
You are NOT allowed to borrow anything from your peer student.
What you have to do
Program the following tasks. The name of your files will be according to the task given in this lab.
Task [100]
Create a dynamic web application using JSP and Java Beans that implements the following functionality:
Step 1: Employee Sign-up: An employee should be able to sign up by providing their name, employee ID, department,
and password.
Step 2: Employee Login: An employee should be able to log in using their employee ID and password.
Step 3 : Employee Profile: An employee should be able to view their profile information, including name, employee ID,
department, and password.
Use JSP Elements and Java Bean to store the employee information and pass it between the JSP pages.
Instructions:
BEST OF LUCK