Geethanjali College of Engineering and
Technology
(UGC AUTONOMOUS INSTITUTION)
(Accredited by NBA and NAAC with ꞌA+ ꞌ grade, Approved by AICTE New Delhi and Affiliated to JNTUH)
Cheeryal (V), Keesara (M), Medchal District – 501 301 (T.S)
Web Technologies Lab
II Year II Semester (AR20)
Laboratory Work Book
20CS22L03
DEPARTMENT OF
COMPUTER SCIENCE AND
ENGINEERING
(2024-2025)
HoD-CSE
Lab In-charge Dr. A Sree Lakshmi
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology
(UGC Autonomous)
Cheeryal (V), Keesara (M), Medchal District – 501 301 (T.S)
DEPARTMENT OF CSE
WEB TECHNOLOGIES
LABORATORY WORKBOOK
Name :V.LAXMI PRIYA
Roll No :23R11A05N9
Class : Branch : CSE
Academic Year : 2024 - 2025
Geethanjali College of Engineering and Technology Page 2
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology
(UGC Autonomous)
Cheeryal (V), Keesara (M), Medchal District – 501 301 (T.S)
DEPARTMENT OF CSE
CERTIFICATE
This is to certify that Mr. /Ms. V. LAXMI PRIYA has satisfactorily completed
number of experiments in the
Web Technologies Laboratory.
Roll No:23R11A05N9 Branch :CSE
Year:II Sem:2nd Academic Year: 2024-2025
Faculty In-charge Head of the Department
Dr. A Sree Lakshmi
Internal Examiner External Examiner
Geethanjali College of Engineering and Technology Page 3
Web Technologies Lab Dept. of CSE
List of Lab Exercises
Web Technologies
S.no. Name of the program Page No.
Write an HTML page including any required Java script that takes
a number from one text field in the range of 0 to 999 and shows it
1 in another text field in words. If the number is out of range, it 45
should show “out of range” and if it is not a number, it should
show “not a number” message in the result box.
Write an HTML page that has one input, which can take multi-
line text and a submit button. Once the user clicks the submit
2 button, itshould show the number of characters, words and lines 49
in the text entered using an alert message. Words are separated
with white space and lines are separated with new line character.
Write an HTML page that contains a selection box with a list of 5
countries. When user selects a country, its capital should be
3 printednext to the list. Add CSS to customize the properties of the 52
font of capital (color, bold, and font size).
Write a XML file which display the Book information which
includes the following: Title of the book, Author Name, ISBN
number, Publisher name, Edition, Price
4 I. Write a Document Type Definition (DTD) to validate the 56
above XML file.
II. Write a XSD to validate the above XML file
Create an XML document that contains 10 users information.
Write a java program, which takes User Id as input and returns the
5 user details by taking the user information from the XML 63
document using
(a)DOM parser and (b) SAX parser
a) Write a Servlet for User validation web application, where
the user submits a login name and password to the server.
6 The name and password are checked against the data 72
already available in Database and if the data matches, a
successful login page is returned. Otherwise a failure
message is shown to the user.
b) Modify the above Program to xml file instead of database. 77
Geethanjali College of Engineering and Technology Page 4
Web Technologies Lab Dept. of CSE
a) Write a Servlet for A simple calculator web application
thattakes two numbers and an operator (+,-,/,*and %)from 85
an HTML page and returns the result page with the
7
operation performed on the operands.
b) Write a Servlet for web application that lists all cookies 93
stored in the browser on clicking “List Cookies” button.
Add cookies if necessary.
a) Write a JSP for User validation web application, where the
user submits a login name and password to the server.
Then name and password are checked against the data
already available in Database and if the data matches, a 99
8 successful login page is returned. Otherwise a failure
message is shown to the user.
b) Write a JSP for A simple calculator web application that
takes two numbers and an operator (+,-,/,*and %)from an 104
HTML page and returns the result page with the operation
performed on the operands.
a).Write a JSP for web application that lists all cookies stored 110
in the browser on clicking “List Cookies” button.
Ass cookies if necessary.
9 b). Write JSP for a web application that takes name and age
from an HTML page. If the age is less than 18, it should send
apage with “Hello <name>, you are not authorized to visit this 115
site” message, where <name> should be replaced with the
entered name. Otherwise it should send “Welcome <name> to
this site” message.
a) Write a PHP for User validation web application, where
the user submits a login name and password to the server. The
name and password are checked against the data already
available in Database and if the data matches, a successful 120
login page is returned. Otherwisea failure message is shown
10
to the user.
b) Write a PHP for A simple calculator web application that
takes two numbers and an operator (+,-,/,*and %)from an
125
HTML page and returns the result page with the operation
performed on the operands.
Write PHP Code Validate the following fields of registration page.
i) Name (it should contains alphabets and length at least 6 130
characters)
11 ii) Password(it should not be less than 6 characters)
iii) Email id (it should not contains any invalid character must
follow the standard pattern name@domain.com)
iv) Phone number (it should contain 10 digits only)
Geethanjali College of Engineering and Technology Page 5
Web Technologies Lab Dept. of CSE
A web application for implementation using PHP.
The user is first served login page which takes user‟s name and
password. After submitting the details the server checks these
values against the data from a database and takes the following
decisions:
12 If name and password match serves a welcome page with user‟s 136
full name
If name matches and password doesn‟t match, then server
„password mismatch‟ page
If name is not found in the full name, it stores, the login name,
password and full name in the database.(hint: Use session for
storing the submitted login name and password)
Basic HTML Programs
S.No. Name of the program Page
no.
Create and test an HTML document for yourself, including your
1. name, address, and electronic mail address. This document
must use several headings and <em>, <strong>, <hr />, <p>, and
<br /> tags and other basic formatting tags. 18
Write a HTML program for the demonstration of Lists.
a. Unordered List
2. b. Ordered List 21
c. Definition List
d. Nested List
Write a HTML program for demonstrating Hyperlinks.
a. Navigation from one page to another.
3. 24
b. Navigation within the page.
c. Navigation from one window to other window
Write a HTML program for displaying your class time-table using 26
4. tables
Write an HTML code to display your education details in a tabular 29
5. format
6. Write a HTML program to develop a Registration Form 31
7. Write a HTML program to develop a Login Page. 35
Geethanjali College of Engineering and Technology Page 6
Web Technologies Lab Dept. of CSE
8. Write an HTML code to create your Institute website, Department 36
Website and Tutorial website for specific subject
Write a HTML program to develop Our college web site using
9. frames. 39
Write HTML for demonstration of cascading style sheets.
a. Embedded style sheets.
10. b. External style sheets. 42
c. Inline styles
Additional Programs
S. No. Name of the Page COs POs PEOs
Program no.
Design an online book store 143 CO1 PO1, PO5, PO9, PEO 1, PEO 2,
website that contains home P12 PEO 3
1 page, login page, catalogue
page.
2. Design a student Result 147 CO1 PO1, PO5, PO9, PEO 1, PEO 2,
analysis web page using P12 PEO 3
CSS
3. Create user authentication 152 CO4 PO1, PO5, PO9, PEO 1, PEO 2,
web page that validates the P12 PEO 3
user details against the
details stored in the data
base using servlets
4. Write a PHP program that 157 CO5 PO1, PO5, PO9, PEO 1, PEO 2,
extracts data from the data P12 PEO 3
base tables and display them.
Geethanjali College of Engineering and Technology Page 7
Web Technologies Lab Dept. of CSE
VISION OF THE INSTITUTION
Geethanjali visualizes dissemination of knowledge and skills to students, who eventually
contribute to well-being of the people of the nation and global community.
MISSION OF THE INSTITUTION
1. To impact adequate fundamental knowledge in all basic science and engineering technical
and Inter - personal skills so students.
2. To bring out creativity in students that would promote innovation, research and
entrepreneurship.
3. To Preserve and promote cultural heritage, humanistic and spiritual values promoting
peace and harmony in society.
VISION OF THE DEPARTMENT
To produce globally competent and socially responsible computer science engineers contributing
to the advancement of engineering and technology which involves creativity and innovation by
providing excellent learning environment with world class facilities.
MISSION OF THE DEPARTMENT
1. To be a center of excellence in instruction, innovation in research and scholarship, and
service to the stake holders, the profession, and the public.
2. To prepare graduates to enter a rapidly changing field as a competent computer science
engineer.
3. To prepare graduate capable in all phases of software development, possess a firm
understanding of hardware technologies, have the strong mathematical background
necessary for scientific computing, and be sufficiently well versed in general theory to allow
growth within the discipline as it advances.
4. To prepare graduates to assume leadership roles by possessing good communication skills,
the ability to work effectively as team members, and an appreciation for their social and
ethical responsibility in a global setting.
Geethanjali College of Engineering and Technology Page 8
Web Technologies Lab Dept. of CSE
PROGRAM EDUCATIONAL OBJECTIVES
1. To provide graduates with a good foundation in mathematics, sciences and engineering
fundamentals required to solve engineering problems that will facilitate them to find
employment in industry and / or to pursue postgraduate studies with an appreciation for
lifelong learning.
2. To provide graduates with analytical and problem solving skills to design algorithms,
other hardware / software systems, and inculcate professional ethics, inter-personal skills
to work in a multi-cultural team.
3. To facilitate graduates to get familiarized with the art software / hardware tools, imbibing
creativity and innovation that would enable them to develop cutting-edge technologies of
multi-disciplinary nature for societal development.
PROGRAM OUTCOMES
1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of complex engineering
problems.
2. Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering problems
and design system components or processes that meet the specified needs with
appropriate consideration for the public health and safety, and the cultural, societal,
and environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and research
methods including design of experiments, analysis and interpretation of data, and synthesis of
the information to provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modelling to complex engineering
activities with an understanding of the limitations.
Geethanjali College of Engineering and Technology Page 9
Web Technologies Lab Dept. of CSE
6. The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent responsibilities
relevant to the professional engineering practice.
7. Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of,
and need for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or
leader in diverse teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and
write effective reports and design documentation, make effective presentations, and give and
receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one‟s own work, as a
member and leader in a team, to manage projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological
change.
PROGRAM SPECIFIC OUTCOMES
1. Demonstrate competency in Programming and problem solving skills and apply those skills
in solving computing problems
2. Select appropriate programming languages, Data Structures and algorithms in combination
with modern technologies and apply them in developing innovative solutions
3. Demonstrate adequate knowledge in emerging technologies
Geethanjali College of Engineering and Technology Page 10
Web Technologies Lab Dept. of CSE
Course Objectives
Develop ability to
1. Understand the basic web concepts and Internet protocols.
2. Acquire knowledge in XML and processing of XML data.
3. Introduce client side scripting with JavaScript and DHTML.
4. Understand Server-side programming with Java Servlets and JSP.
5. Implement Server side scripting with PHP.
Course Outcomes (COs)
Upon successful completion of the course, student would be able to:
CO1. Design static Web Pages with HTML and CSS
CO2. Implement client side scripts using Java Script
CO3. Prepare and parse XML schemas
CO4. Implement and deploy server side programs using Servlets, JSP and PHP
Geethanjali College of Engineering and Technology Page 11
Web Technologies Lab Dept. of CSE
CO – PO Mapping
Course Title POs PSOs
Lab
Web Technologies Lab experiment
1 2 3 4 5 6 7 8 9 10 11 12 1 2 3
20CS22L03 numbers
1, 2, 3
CO1. Design static
WebPages with 3 3 3 1 3 2 3 3
HTML and CSS
CO2. Implement
client side scripts
using Java Script 1, 2, 3 3 3 3 1 3 2 3 1
CO3. Prepare and 4, 5
parse XML 3 3 3 1 3 2 1 1
schemas
CO4. Implement and
deploy server side 6, 7, 8, 9,
programs using 10, 11,
12, 13 3 3 3 1 3 2 3 3
Servlets, JSP and PHP
Geethanjali College of Engineering and Technology Page 12
Web Technologies Lab Dept. of CSE
Prerequisites:
1. 20CS11L01-PROGRAMMING FOR PROBLEM SOLVING-I LAB
2. 20CS21L02-OBJECT ORIENTED PROGRAMMING LAB
3. 20CS21L03-DATABASE MANAGEMENT SYSTEMS LAB
INSTRUCTIONS TO THE STUDENTS:
1. Students are required to attend all labs.
2. Students will work individually in computer laboratories.
3. While coming to the lab bring the observation book and Work book etc.
4. Before coming to the lab, prepare the pre lab questions. Read through the lab
experiment to familiarize you.
5. Utilize 3 hours time properly to perform the experiment and noting down the
outputs.
6. If the experiment is not completed in the prescribed time, the pending work has to
be done in the leisure hour or extended hours.
7. You will be expected to submit the completed work book according to the
deadlines set up by your instructor.
INSTRUCTIONS TO LABORATORY TEACHERS:
1. Observation book and lab records submitted for the lab work are to be checked and
signed before the next lab session.
2. Students should be instructed to switch ON the power supply after the connections
are checked by the lab assistant / teacher.
3. The promptness of submission should be strictly insisted by awarding the marks
accordingly.
4. Ask viva questions at the end of the experiment.
5. Do not allow students who come late to the lab class.
6. Encourage the students to do the experiments innovatively.
7. Fill continuous Evaluation sheet, on continuous basis.
8. Ensure that the students are dressed in a formal way.
Geethanjali College of Engineering and Technology Page 13
Web Technologies Lab Dept. of CSE
Scheme of Lab Exam Evaluation:
Evaluation of Internal Marks:
Evaluation of Internal Marks:
a) 10 Marks are awarded for day-to-day work
1) Record----------5Marks
2) Observation book----------5 Marks
b) 10 marks for viva-voce (or) tutorial (or) case study (or) application (or) poster presentation of
the concerned.
1) viva-voce on course content----------5 Marks
2) viva voce/presentation on Project (PBL)-----5 marks
c) 10 Marks are awarded for conducting laboratory test as follows:
1) Write up and program----------------5 Marks
2) Execution of Program----------------5Marks
d) Laboratory project/ (PBL)---------------10 marks
Evaluation of External Marks:
60 Marks are awarded for conducting laboratory test as follows:
1) Write up and Program----------25 Marks
2) Evaluation of results------------15 Marks
3) presentation on another experiment/program in the same laboratory-----10 Marks
4) Viva-Voce-----------------------10Marks
Geethanjali College of Engineering and Technology Page 14
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 15
Web Technologies Lab Dept. of CSE
INDEX
S.No Name of Experiment Date of Date of
Exp. Submission Marks Signature Remarks
1.
Geethanjali College of Engineering and Technology Page 16
Web Technologies Lab Dept. of CSE
INDEX
S.No Name of Experiment Date of Date of Marks Signature Remarks
Exp. Submission
Geethanjali College of Engineering and Technology Page 17
Web Technologies Lab Dept. of CSE
INDEX
S.No Name of Experiment Date of Date of
Marks Signature Remarks
Exp. Submission
Geethanjali College of Engineering and Technology Page 18
Web Technologies Lab Dept. of CSE
Program 1:- Date:
Write an HTML page including any required Javascript that takes a number from one textfield in
the range of 0 to 999 and shows it in another text field in words. If the number is out of range, it
should show “out of range” and if it is not a number, it should show “not a number” message in
the result box.
Prerequisite: Students should have knowledge on designing of pages using html
Objective: To introduce java script to the student
Outcome: The student will have learned the basics of Java scripts and the UI components
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Number to Words Converter</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 50px;
}
.container {
max-width: 400px;
margin: auto;
text-align: center;
}
input, button {
margin: 10px 0;
padding: 10px;
font-size: 16px;
}
</style>
</head>
<body>
<div class="container">
<h2>Number to Words Converter</h2>
<label for="numberInput">Enter a number (0-999):</label><br>
<input type="text" id="numberInput" placeholder="Enter number"><br>
<button onclick="convertToWords()">Convert</button><br>
<label for="result">Result:</label><br>
<input type="text" id="result" readonly>
</div>
<script>
Geethanjali College of Engineering and Technology Page 19
Web Technologies Lab Dept. of CSE
const ones = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"];
const teens = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen",
"nineteen"];
const tens = ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"];
function numberToWords(num) {
if (num === 0) return "zero";
let words = "";
if (Math.floor(num / 100) > 0) {
words += ones[Math.floor(num / 100)] + " hundred ";
}
num %= 100;
if (num >= 10 && num <= 19) {
words += teens[num - 10];
} else {
if (Math.floor(num / 10) > 0) {
words += tens[Math.floor(num / 10)] + " ";
}
words += ones[num % 10];
}
return words.trim();
}
function convertToWords() {
const input = document.getElementById("numberInput").value.trim();
const resultField = document.getElementById("result");
if (isNaN(input)) {
resultField.value = "not a number";
return;
}
const number = parseInt(input);
if (number < 0 || number > 999) {
resultField.value = "out of range";
return;
}
resultField.value = numberToWords(number);
}
</script>
</body>
</html>
Geethanjali College of Engineering and Technology Page 20
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 21
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 22
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 23
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 24
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 25
Web Technologies Lab Dept. of CSE
Viva Questions:
What is an example of client side scripting language?
JavaScript is a popular client-side scripting language used for creating interactive and dynamic web
pages.
What are JavaScript data types?
JavaScript has the following data types:
Primitive Data
Non Primitive Data
How do we submit the form in JavaScript?
We submit it by the following code line
document.getElementById("myForm").submit();
What is JavaScript?
JavaScript is a versatile, high-level programming language used to create dynamic and interactive
web applications.
Geethanjali College of Engineering and Technology Page 26
Web Technologies Lab Dept. of CSE
Program 2:- Date:
Write an HTML page that has one input, which can take multi-line text and a submit button.
Once the user clicks the submit button, it should show the number of characters, words and lines
in the text entered using an alert message. Words are separated with white space and lines are
separated with new line character.
Prerequisite: Students should have knowledge on HTML
Objective: To show the student how the input form works in HTML
Outcome: The student will have learned how to write functions and how to create forms for
inputs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>23r11a05n9</title>
<script>
function analyzeText() {
let text = document.getElementById("textInput").value;
let charCount = text.length;
let wordCount = text.trim() === "" ? 0 : text.trim().split(/\s+/).length;
let lineCount = text.split("\n").length;
alert("Characters: " + charCount + "\nWords: " + wordCount + "\nLines: " + lineCount);
}
</script>
</head>
<body>
<h2>Text Statistics Counter</h2>
<textarea id="textInput" rows="10" cols="50" placeholder="Enter your text here..."></textarea><br>
<button onclick="analyzeText()">Submit</button>
</body>
</html>
Geethanjali College of Engineering and Technology Page 27
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 28
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 29
Web Technologies Lab Dept. of CSE
Viva Questions:
What is the tag for selection of multi tag text in Html?
The <select> tag with the multiple attribute allows users to select multiple options in a dropdown.
What is an Empty HTML Tag?
An empty HTML tag is a tag that does not have a closing tag and does not contain any content.
Examples <br>,<img>,<hr>
Explain about frames used in HTML?
Frames in HTML allow a webpage to be divided into multiple sections where each section can load
a separate document. They were created using the <frameset> and <frame> tags.
What is the use of attributes used in HTML?
Attributes provide additional information about an HTML element and define its behavior or
appearance.
Geethanjali College of Engineering and Technology Page 30
Web Technologies Lab Dept. of CSE
Program 3:- Date:
Write an HTML page that contains a selection box with a list of 5 countries. When the user
selects a country, its capital should be printed next to the list. Add CSS to customize the
properties of the font of the capital (color, bold and font size)
Prerequisite: Students should have knowledge in HTML
Objectives: To teach the student to connect to the server
Outcome: The student will have learned to connect to the database
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>23r11a05n8</title>
<style>
#capital {
color: blue;
font-weight: bold;
font-size: 18px;
}
</style>
<script>
function showCapital() {
let country = document.getElementById("countrySelect").value;
let capitals = {
"USA": "Washington, D.C.",
"UK": "London",
"France": "Paris",
"Germany": "Berlin",
"Japan": "Tokyo"
};
document.getElementById("capital").innerText = capitals[country];
}
</script>
</head>
<body>
<h2>Select a Country</h2>
<select id="countrySelect" onchange="showCapital()">
<option value="Country">Country</option>
<option value="USA">USA</option>
<option value="UK">UK</option>
<option value="France">France</option>
Geethanjali College of Engineering and Technology Page 31
Web Technologies Lab Dept. of CSE
<option value="Germany">Germany</option>
<option value="Japan">Japan</option>
</select>
<p>Capital: <span id="capital"></span></p>
</body>
</html>
Geethanjali College of Engineering and Technology Page 32
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 33
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 34
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 35
Web Technologies Lab Dept. of CSE
Viva Questions:
What are cascading style sheets?
CSS is a stylesheet language used to control the layout and appearance of HTML elements. It
enables web developers to apply styles like colors, fonts, spacing, and positioning to create visually
appealing web pages.
What are the advantages / disadvantages of various style methods?
Inline CSS
Advantages: Quick and specific to a single element.
Disadvantages: Hard to maintain, no reusability, clutters HTML.
Internal CSS
Advantages: Styles apply to the whole page, no extra file needed.
Disadvantages: Doesn't work across multiple pages, increases page size.
External CSS
Advantages: Reusable across multiple pages, better for large projects, easier to maintain.
Disadvantages: Requires an extra file load, styles won’t apply if the file is missing.
What is property?
A CSS property defines a specific aspect of an element's style, such as color, font-size, or margin.
What is the css clear property?
The clear property is used to control the behavior of floated elements, preventing elements from
appearing next to them.
What are the necessities of using html forms?
HTML forms allow users to input and submit data to a server. They are essential for
Collecting user information (e.g., login, registration),Enabling search functionalities.
Geethanjali College of Engineering and Technology Page 36
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 37
Web Technologies Lab Dept. of CSE
Program 4:- Date:
Write an XML file which displays the Book information which includes the following:
Title of the book, Author Name, ISBN number, Publisher name, Edition, Price
I. Write a Document Type Definition (DTD) to validate the above XML file.
II. Write a XSD to validate the above XML file
Prerequisite: Students should have knowledge in HTML
Objectives: To teach the student to connect to the server
Outcome: The student will have learned to connect to the database
XML with DTD Program
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE BookCatalog SYSTEM "books.dtd">
<BookCatalog>
<Book>
<Title>The Great Gatsby</Title>
<Author>F. Scott Fitzgerald</Author>
<ISBN>9780743273565</ISBN>
<Publisher>Scribner</Publisher>
<Edition>1st</Edition>
<Price>12.99</Price>
</Book>
<Book>
<Title>To Kill a Mockingbird</Title>
<Author>Harper Lee</Author>
<ISBN>9780061120084</ISBN>
<Publisher>HarperPerennial</Publisher>
<Edition>50th Anniversary</Edition>
<Price>14.99</Price>
</Book>
</BookCatalog>
<!-- books.dtd -->
<!ELEMENT BookCatalog (Book+)>
<!ELEMENT Book (Title, Author, ISBN, Publisher, Edition, Price)>
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Author (#PCDATA)>
<!ELEMENT ISBN (#PCDATA)>
<!ELEMENT Publisher (#PCDATA)>
<!ELEMENT Edition (#PCDATA)>
<!ELEMENT Price (#PCDATA)>
Geethanjali College of Engineering and Technology Page 38
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 39
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 40
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 41
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 42
Web Technologies Lab Dept. of CSE
XSD Program
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="BookCatalog">
<xs:complexType>
<xs:sequence>
<xs:element name="Book" type="BookType" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="BookType">
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Author" type="xs:string"/>
<xs:element name="ISBN" type="ISBNType"/>
<xs:element name="Publisher" type="xs:string"/>
<xs:element name="Edition" type="xs:string"/>
<xs:element name="Price" type="PriceType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="ISBNType">
<xs:restriction base="xs:string">
<xs:pattern value="\d{10}|\d{13}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="PriceType">
<xs:restriction base="xs:decimal">
<xs:minInclusive value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
Geethanjali College of Engineering and Technology Page 43
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 44
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 45
Web Technologies Lab Dept. of CSE
Viva Questions:
What does XML stands for?
XML stands for: eXtensible Markup Language.
What does DTD stands for?
DTD stands for: Document Type Definition.
Are there any built-in tags in XML?
No, XML does not have predefined or built-in tags. Users define their own tags based on the
structure they need.
What is a schema?
A schema defines the structure, elements, and data types of an XML document. It ensures that the
XML data is valid and follows specific rules. XML Schema (XSD) is a commonly used format for
defining XML schemas.
Geethanjali College of Engineering and Technology Page 46
Web Technologies Lab Dept. of CSE
Program 5:- Date:
Create an XML document that contains 10 users information .Write a java program, which
takes User Id as input and returns the user details by taking the user information from the
XML document using
(a) DOM parser
(b) SAX parser
Prerequisite: Students must have basic knowledge in data bases.
Objective: To make the student understand how an XML file works
Outcome: The student will have learned how to use an XML file
DOM Parser Program :
import javax.xml.parsers.*;
import org.w3c.dom.*;
import java.io.File;
import java.util.Scanner;
public class DOMParserExample {
public static void main(String[] args) {
try {
// Load XML file
File inputFile = new File("users.xml");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(inputFile);
document.getDocumentElement().normalize();
// Get user input
Scanner scanner = new Scanner(System.in);
System.out.print("Enter User ID: ");
String inputId = scanner.nextLine();
// Get all users
NodeList nodeList = document.getElementsByTagName("user");
// Iterate over user nodes
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element userElement = (Element) node;
// Get User ID
String userId = userElement.getAttribute("id");
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 47
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 37
// Check if matches input
if (userId.equals(inputId)) {
String name = userElement.getElementsByTagName("name").item(0).getTextContent();
String email = userElement.getElementsByTagName("email").item(0).getTextContent();
String age = userElement.getElementsByTagName("age").item(0).getTextContent();
String city = userElement.getElementsByTagName("city").item(0).getTextContent();
System.out.println("\nUser Found:");
System.out.println("ID: " + userId);
System.out.println("Name: " + name);
System.out.println("Email: " + email);
System.out.println("Age: " + age);
System.out.println("City: " + city);
return;
}
}
}
System.out.println("User ID not found.");
} catch (Exception e) {
e.printStackTrace();
}
}
}
Geethanjali College of Engineering and Technology Page 48
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 49
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 50
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 51
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 52
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 53
Web Technologies Lab Dept. of CSE
SAX Parser Program:
import javax.xml.parsers.SAXParser;
import javax.xml.parsers. SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import java.io.File;
import java.util.Scanner;
class UserHandler extends DefaultHandler {
private String userId;
private boolean isName, isEmail, isAge, isCity
private String foundName, found Email, foundAge, foundCity;
private boolean userFound false;
public UserHandler (String userId) {
this.userId = userId;
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
{
if (qName.equalsIgnoreCase("user")) {
String id attributes.getValue("id");
if (id.equals(userId)) {
userFound = true;
}
} if (userFound) {
if (qName.equalsIgnoreCase("name")) isName = true;
else if (qName.equalsIgnoreCase("email")) isEmail = true;
else if (qName.equalsIgnoreCase("age")) isAge = true;
else if (qName.equalsIgnoreCase("city")) isCity = true;
else if (qName.equalsIgnoreCase("email")) isEmail = true;
else if (qName.equalsIgnoreCase("age")) isAge = true;
else if (qName.equalsIgnoreCase("city")) isCity = true;
}
}
public void characters (char[] ch, int start, int length) throws SAXException {
isEmail = false;
if (isName) {
isName = false;
} else if (isEmail) {
foundEmail = new String(ch, start, length);
} else if (isAge) {
isAge = false;
} else if (isCity) {
foundCity = new String(ch, start, length);
foundName = new String(ch, start, length);
foundAge = new String(ch, start, length);
Geethanjali College of Engineering and Technology Page 54
Web Technologies Lab Dept. of CSE
isCity = false;
}
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 40
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (qName.equalsIgnoreCase("user") && userFound) {
System.out.println("User Found:");
System.out.println("ID: + userId);
System.out.println("Name: + foundName);
System.out.println("Email: + foundEmail);
System.out.println("Age: + foundAge);
}
System.out.println("City: " + foundCity);
userFound = false;
}
if (qName.equalsIgnoreCase("users") && ! UserMatch)
{
}
System.out.println("User Not Found");
}
public class SAXParserExample {
}
public static void main(String[] args) {
try {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter User ID: ");
String inputId = scanner.nextLine();
File inputFile = new File("users.xml");
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser factory.newSAXParser();
UserHandler handler = new UserHandler(inputId);
saxParser.parse(inputFile, handler);
} catch (Exception e) {
e.printStackTrace();
Geethanjali College of Engineering and Technology Page 55
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 56
Web Technologies Lab Dept. of CSE
Viva Questions:
What is XML parser?
An XML parser is a software component that reads XML documents and provides access to their
content and structure. It checks for well-formedness and, in some cases, validates XML documents
against a schema.
What is DOM?
DOM (Document Object Model) is a tree-based API for parsing XML documents. It represents the
entire document as a tree structure in memory, allowing easy navigation and manipulation of
elements.
What is SAX?
SAX (Simple API for XML) is an event-driven XML parsing approach where the parser reads the
XML document sequentially and triggers events (like startElement, endElement, characters) when
encountering different XML components. It does not load the entire document into memory.
What are the interfaces of SAX?
The main interfaces in SAX include:
ContentHandler: Handles XML document content (e.g., elements, attributes).
ErrorHandler: Handles errors during parsing.
What is the difference between SAX parser and DOM parser
SAX is event-driven and processes XML sequentially, using less memory but allowing only forward
access. DOM loads the entire document into memory as a tree, enabling random access and
modification but consuming more resources. SAX is faster for large files, while DOM is better for
complex data manipulation.
Geethanjali College of Engineering and Technology Page 57
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 58
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 59
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 60
Web Technologies Lab Dept. of CSE
Program 6:- Date:
a) Write a Servlet for User validation web application, where the user submits a login name
and password to the server. The name and password are checked against the data already
available in Database and if the data matches, a successful login page is returned.Otherwise a
failure message is shown to the user.
Prerequisite: Students must have basic knowledge on JAVA & JDBC.
Objective: To make the student create Dynamic Websites.
Outcome: The student will have learned how Servers work.
Home.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class HomePage extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Login Page</title></head>");
out.println("<body>");
out.println("<h2>Login</h2>");
out.println("<form action='login' method='post'>");
out.println("Username: <input type='text' name='username' ><br><br>");
out.println("Password: <input type='password' name='password'><br><br>");
out.println("<input type='submit' value='Login'>");
out.println("</form>");
out.println("</body>");
out.println("</html>");
}
}
Geethanjali College of Engineering and Technology Page 61
Web Technologies Lab Dept. of CSE
LoginServlet.java
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String username = request.getParameter("username");
String password = request.getParameter("password");
if (validateUser(username, password)) {
out.println("<h2>Login Successful!</h2>");
} else {
out.println("<h2>Login Failed! Invalid username or password.</h2>");
}
}
private boolean validateUser(String username, String password) {
boolean isValid = false;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb", "root", "Gcet@123");
String sql = "SELECT * FROM users WHERE username = ? AND password = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, username);
pstmt.setString(2, password);
rs = pstmt.executeQuery();
Geethanjali College of Engineering and Technology Page 62
Web Technologies Lab Dept. of CSE
if (rs.next()) {
isValid = true;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (rs != null) rs.close();
if (pstmt != null) pstmt.close();
if (conn != null) conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return isValid;
}
}
Geethanjali College of Engineering and Technology Page 63
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 64
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 65
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 66
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 67
Web Technologies Lab Dept. of CSE
Viva Questions:
What is the statement used to connect to the Database in servlet?
Connection conn = DriverManager.getConnection(DB_URL, USER, PASSWORD);
What is the role of doGet() in Servlet?
The doGet() method in a servlet is part of the HttpServlet class, and it handles HTTP GET requests
from clients (typically browsers).
What is the root directory used for servlets?
The root directory for servlets in a web application typically refers to the WEB-INF directory structure
within a Java web application.
Geethanjali College of Engineering and Technology Page 68
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 69
Web Technologies Lab Dept. of CSE
Program 6:- Date:
b. Modify the above program to use an xml file instead of database
Prerequisite: Students should have basic understanding on how servers work.
Objective: Introducing XML for form validation.
Outcome: The student will have learned to deal with server connection and XML Schema.
Web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="3.0">
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>HomePage</servlet-name>
<servlet-class>HomePage</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HomePage</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Geethanjali College of Engineering and Technology Page 70
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 71
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 72
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 73
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 74
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 75
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 76
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 77
Web Technologies Lab Dept. of CSE
Viva Questions:
What are the key factors for using an XML file?
To store and transport structured data in a platform-independent way.
Difference between HTML and XML
HTML displays data; XML stores and structures data.
how DTD is applied to the XML document
By linking it internally or externally using the <!DOCTYPE> declaration.
Define element and attribute in an XML Document
Element:
A tag that holds data. Example: <name>John</name>
Attribute:
Extra info within a tag. Example: <user id="101">John</user>
Geethanjali College of Engineering and Technology Page 78
Web Technologies Lab Dept. of CSE
Program 7:- Date:
a) Write a Servlet for A simple calculator web application that takes two numbers and an
operator (+,-,/,*and %)from an HTML page and returns the result page with the operation
performed on the operands.
Prerequisite: Students must have basic knowledge on JAVA & JDBC.
Objective: To make the student create Dynamic Websites.
Outcome: The student will have learned how Servers work.
Geethanjali College of Engineering and Technology Page 79
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 80
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 81
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 82
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 83
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 84
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 85
Web Technologies Lab Dept. of CSE
Viva Questions:
What is the significance of a HTML form
How to add buttons in HTML layout.
What happens when init() is invoked
In relation to the above program state the significance of HTTPRequest.
Geethanjali College of Engineering and Technology Page 86
Web Technologies Lab Dept. of CSE
Program 7:- Date:
b)Write a Servlet for web application that lists all cookies stored in the browser on
clicking “List Cookies” button. Add cookies if necessary.
Prerequisite: Students must have basic knowledge on Cookies
Objective: To make the student create Dynamic Websites.
Outcome: The student will have learned Sessions and how Cookies work.
Geethanjali College of Engineering and Technology Page 87
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 88
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 89
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 90
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 91
Web Technologies Lab Dept. of CSE
Viva Questions:
What is a Cookie?
What is the lifetime of cookie?
What kind of data does a cookie supports?
Geethanjali College of Engineering and Technology Page 92
Web Technologies Lab Dept. of CSE
Program 8:- Date:
a) Write a JSP for User validation web application, where the user submits a login name and
password to the server. Then name and password are checked against the data alreadyavailable
in Database and if the data matches, a successful login page is returned. Otherwise a failure
message is shown to the user.
Prerequisite: Students must have basic knowledge on Servlets
Objective: To make the student create Dynamic Websites.
Outcome: The student will have learned applications of JSP
Geethanjali College of Engineering and Technology Page 93
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 94
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 95
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 96
Web Technologies Lab Dept. of CSE
Viva Questions:
Why does the JSP has to be converted into Servlet while execution?
What is the difference between JSP and Servlets?
Is JSP a replacement to Servlet?
Geethanjali College of Engineering and Technology Page 97
Web Technologies Lab Dept. of CSE
Program 8:- Date:
b) Write a JSP for A simple calculator web application that takes two numbers and an operator
(+,-,/,*and %)from an HTML page and returns the result page with the operation performed on
the operands.
Prerequisite: Students must have basic knowledge on Servlets
Objective: To make the student create Dynamic Websites.
Outcome: The student will have learned applications of JSP
Geethanjali College of Engineering and Technology Page 98
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 99
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 100
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 101
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 102
Web Technologies Lab Dept. of CSE
Viva Questions:
How JSP page is converted to Servlet?
Explain about JSP Processing?
JSP method to get the data from html page?
Geethanjali College of Engineering and Technology Page 103
Web Technologies Lab Dept. of CSE
Program 9:- Date:
a) Write a JSP for web application that lists all cookies stored in the browser on
clicking “List Cookies” button. Add cookies if necessary.
Prerequisite: Students must have basic knowledge on Servlets and Cookies
Objective: To make the student create Dynamic Websites.
Outcome: The student will have learned applications of Cookies in JSP
Geethanjali College of Engineering and Technology Page 104
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 105
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 106
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 107
Web Technologies Lab Dept. of CSE
Viva Questions:
What are the implicit objects in JSP?
How exceptions can be handled in JSP?
What are the action tags in JSP?
Geethanjali College of Engineering and Technology Page 108
Web Technologies Lab Dept. of CSE
Program 9:- Date:
b) Write JSP for a web application that takes name and age from an HTML page. If theage is
less than 18, it should send a page with “Hello <name>, you are not authorized to visit this
site” message, where <name> should be replaced with the entered name. Otherwise it should
send “Welcome <name> to this site” message.
Prerequisite: Students must have basic knowledge on JSPs.
Objective: To make the student create Dynamic Websites.
Outcome: The student will have learned applications of JSP.
Geethanjali College of Engineering and Technology Page 109
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 110
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 111
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 112
Web Technologies Lab Dept. of CSE
Viva Questions:
Explain role of useBean action tag in JSP?
To Display the output which method is used in JSP?
What are the life-cycle methods of JSP?
Geethanjali College of Engineering and Technology Page 113
Web Technologies Lab Dept. of CSE
Program 10:- Date:
a) Write a PHP for User validation web application, where the user submits a login name and
password to the server. The name and password are checked against the data alreadyavailable
in Database and if the data matches, a successful login page is returned. Otherwise a failure
message is shown to the user.
Prerequisite: Students must have good knowledge on HTML & Server side Programming.
Objective: To make the student create Dynamic Websites.
Outcome: The student will have learned applications of PHP.
Geethanjali College of Engineering and Technology Page 114
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 115
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 116
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 117
Web Technologies Lab Dept. of CSE
Viva Questions:
List the applications of PHP.
What are the Data types in PHP?
Explain String functions in PHP.
Geethanjali College of Engineering and Technology Page 118
Web Technologies Lab Dept. of CSE
Program 10:- Date:
b) Write a PHP for A simple calculator web application that takes two numbers and an operator
(+, -, /, * and %) from an HTML page and returns the result page with the operation performed
on the operands.
Prerequisite: Students must have good knowledge on HTML & Server side Programming.
Objective: To make the student create Dynamic Websites.
Outcome: The student will have learned applications of PHP.
Geethanjali College of Engineering and Technology Page 119
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 120
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 121
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 122
Web Technologies Lab Dept. of CSE
Viva Questions:
How can an HTML page be linked to the PHP
Explain types of arrays in PHP.
How to create a function PHP? Give an example.
Geethanjali College of Engineering and Technology Page 123
Web Technologies Lab Dept. of CSE
Program 11:- Date:
Write PHP code Validate the following fields of registration page.
i) Name (it should contains alphabets and length at least 6 characters)
i) Password (it should not be less than 6 characters)
i) Email id (it should not contains any invalid character must follow the
standard pattern (name@domain.com)
iv) Phone number(it should contain 10 digits only)
Prerequisite: Students must have good knowledge on HTML & Server side Programming.
Objective: To make the student create Dynamic Websites.
Outcome: The student will have learned applications of PHP.
Geethanjali College of Engineering and Technology Page 124
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 125
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 126
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 127
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 128
Web Technologies Lab Dept. of CSE
Viva Questions:
What is the use of POST and GET methods in PHP?
How to create a session in PHP?
How to upload a file in PHP?
Geethanjali College of Engineering and Technology Page 129
Web Technologies Lab Dept. of CSE
Program 12:- Date:
A web application for implementation using PHP:
The user is first served login page which takes user‟s name and password. After submitting the
details the server checks these values against the data from a data base and takes the following
decisions
If name and password match serves a welcome page with user‟s full name.
If name matches and password doesn‟t match, then serves „password mismatch‟ page
If name is not found in the database serves a registration page, where user‟s full name is asked
and on submitting the full name, it stores, the login name, password and full name inthe data
base (hint: Use session for storing the submitted login name and password)
Prerequisite: Students must have good knowledge on HTML & Server side
Programming. Objective: To make the student create Dynamic Websites.
Outcome: The student will have learned applications of PHP.
Geethanjali College of Engineering and Technology Page 130
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 131
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 132
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 133
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 134
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 135
Web Technologies Lab Dept. of CSE
Viva Questions:
Statement used to connect php to mysql database.
What is the use of Isset()?
Explain mysqli_fetch_assoc().
Geethanjali College of Engineering and Technology Page 136
Web Technologies Lab Dept. of CSE
Additional Programs
Program 1:- Date:-
Create and test an HTML document for yourself, including your name, address, and electronic
mail address. This document must use several headings and <em>, <strong>, <hr />, <p>,
and <br /> tags and other basic formatting tags.
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Program 2:- Date:-
Write a HTML program for the demonstration of Lists.
a. Unordered List
b. Ordered List
c. Definition List
d. Nested List
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Program 3:- Date:-
Write a HTML program for demonstrating Hyperlinks.
a. Navigation from one page to another.
b. Navigation within the page.
c. Navigation from one window to other window
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Program 4:- Date:-
Write a HTML program for displaying your class time-table using tables
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Program 5 :- Date:-
Write an HTML code to display your education details in a tabular format
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Program 6 :- Date:-
Write a HTML program to develop a Registration Form
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Program 136 Date:-
Write a HTML program to develop a Login Page.
Geethanjali College of Engineering and Technology Page
Web Technologies Lab Dept. of CSE
Program 8:- Date:-
Write an HTML code to create your Institute website, Department Website and
Tutorial website for specific subject.
Geethanjali College of Engineering and Technology Page 137
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 138
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 139
Web Technologies Lab Dept. of CSE
Program 9:- Date:-
Write a HTML program to develop our college website using frames.
Geethanjali College of Engineering and Technology Page 140
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 141
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 142
Web Technologies Lab Dept. of CSE
Program 10:- Date:-
Write HTML for demonstration of Cascading Style Sheets.
a. Internal style sheets.
b. External style sheets.
c. Inline styles
Geethanjali College of Engineering and Technology Page 143
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 144
Web Technologies Lab Dept. of CSE
Geethanjali College of Engineering and Technology Page 145
Web Technologies Lab Dept. of CSE