0% found this document useful (0 votes)
9 views70 pages

Computer Science Practical Record

Uploaded by

navin.m23
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views70 pages

Computer Science Practical Record

Uploaded by

navin.m23
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

RECORD NOTEBOOK

Name:

Register No:

Subject Code/Title:

Year/Semester:
BONAFIDE CERTIFICATE

This is to certify that Mr./Ms.

[Link]. of Semester

Year B.E Computer Science and Engineering has completed his/her practical

work in the

laboratory during the academic year 2024-25.

Faculty In-charge Head of the Department

Submitted for the University practical examination held on :

INTERNAL EXAMINER EXTERNAL EXAMINER


LIST OF EXPERIMENTS

EXP. DATE Name of the Program Page No. Marks Signature


NO.
1 Creating a Webpage using Image
Map

2 Creating a Webpage with Cascading


Style Sheets
3
WEB Form Validation Using DHTML

4
Installation Of APACHE TOMCAT
Web Server

5a
Invoke Servlets From HTML Forms

5b
Session Tracking Using HIT Count

6a Online Examination Using JSP and


Database

6b Student Information System Using


JSP And Database

7 Creating Web Pages Using


XML Document

8a Program Using DOM Parser

8b Program Using SAX Parser

9 Program Using AJAX

10 Project Work Online Flight Ticket


Reservation

2
Ex No:1 CREATING A WEBPAGE USING IMAGE MAP
Date :

Aim: To create a web page with the following using HTML.


i) To embed an image map in a web page.
ii) To fix the hot spots.
iii) Show all the related information when the hot spots are clicked

Algorithm:
Step 1: Create a html file with map tag.
Step 2: Set the source attribute of the img tag to the location of the image and also set the use
map attribute.
Step 3: Specify an area with name, shape and href set to the appropriate values.
Step 4: Repeat step 3 as many hot spots you want to put in the map.
Step 5: Create html files for each and every hot spots the user will select.

Program:
[Link]
<html>
<head><title>IMAGE MAP USING HTML</title>
<body bgcolor="blue">
<center><font face=" Times New Roman" color="yellow"><h1>India</h1></font></center>
<center><img src="[Link]" usemap="#India"></center>
<map name="India">
<area shape="rect" coords="278,671,310,718" href="[Link]" title="CHENNAI">
<area shape="circle" coords="141,429,25" href="[Link]" title="MUMBAI">
<area shape="rect" coords="157,547,199,566" href="[Link]" title="GOA">
</map>
</body>
</html>
[Link]
<html>
<head>
<title>CHENNAI</title>
</head>
<body bgcolor="yellow">
<center><font face=" Algerian" size="12" color="red">CHENNAI</font></center><br>
<marquee direction=”right”> Vanakam Chennai </marquee>
welcome to chennai
</body>
</html>
[Link]
<html>
<head>
<title>MUMBAI</title>
</head>
<body bgcolor="pink">
3
<center><font face="Magneto Bold" size="12" color="orange">MUMBAI</font></center><br>
<marquee>namsathy</marquee>
sorry for the inconvenience mumbai official site under maintainence
</body>
</html>
[Link]
<html>
<head>
<title>GOA</title>
</head>
<body bgcolor="red">
<center><font face="Magneto Bold" size="12" color="green">GOA</font></center><br>
<marquee>tourist spot</marquee>
<ul type="disc">
<li>arabic sea</li>
<li>church</li>
</ul>
</body>
</html>
Output

4
RESULT: Thus created a web page using HTML has been ExecutedSuccessfully.

5
Ex No:2 CREATING A WEBPAGE WITH CASCADING STYLE SHEETS
Date :

Aim:
To create a web page with all types of cascading style sheets

Algorithm:

Step 1: Declare as individual element by using style attribute (inline style)


Step 2: Embed the entire style rules in an HTML document head section (embedded style)by
using <style> element follows <style type=”text/css”>
Step 3: Create separate document that contains only css rule(external style)save as
[Link]
Step 4: Create a link between external style rule and HTML document by using <link>element
as follows<link rel=”stylesheet” type=”text/css” href=”[Link]”>
Step 5: Open the browser and display the webpage.

Program:
main [Link]
<html>
<head>
<title>COLLEGE</title>
<style type="text/css">
ul{list-style-type:square}
body{
background-image: url("[Link]");
background-repeat:repeat-x;
background-position:bottom
}
p{font-family:Papyrus;font-size:20px;color:green}
h1{font-family:Script MT Bold;font-size:25px}
</style>
</head>
<body>
<p><marquee direction="right"><center>LOYOLA INSTITUT
OFTECHNOLOGY</center></marquee></p>
<pre>palanchur,
lit@[Link]
contact no:044-64543798</pre>
<center><p>DEPARTMENT</p></center>
<ul>
<li><h1><a href=[Link]>IT</a></h1></li>

6
<li><h1><a href=[Link]>CSE</a></h1></li>
<li><h1><a href=[Link]>ECE</a></h1></li>
<li><h1><a href=[Link]>MECH</a></h1></li>
</ul>
</body>
</html>

[Link]
</body>
</html>
<html>
<head>
<title>INFORMATION TECHNOLOGY</title>
<link rel="stylesheet" type="text/css" href="[Link]">
</head>
<body>
<h1>IT is interesting department with lot of interesting subjects</h1>
</body>
</html>

[Link]
h1{font-family:Script MT Bold;font-size:50px;color:red}
body{background-color:green}

[Link]
<head>
<title>CSE</title>
<style type="text/css">
p{font-family:Times New Roman;font-size:55px;text-transform:uppercase;font-
weight:bold;color:sky blue}
h1{font-family:Old English Text MT;font-weight:bold}
body{background-color:yellow}
table,th,td{border:1px solid black}
th{color:green;background-color:red}
</style>
</head>
<body>
<marquee><p>Computer science engineering</p></marquee>
<table>
<tr>
<th>SEMESTER</th>
<th>SUBJECT</th>
</tr>
<tr>
<td>1</td>
<td>COPMTER PROGRAMMING</td>

7
</tr>
<tr>
<td>2</td>
<td>OOPS</td>
</tr>
<tr>
<td>3</td>
<td>JAVA PROGRAMMING</td>
</tr>
</body>
</html>

[Link]
<html>
<head>
<title>ECE</title>
</head>
<body bgcolor="sky blue">
<center>
<p style="font-family:Pristina;text-transform:uppercase;FONT-SIZE:30">ECE<br><br>
<marquee direction="down">It is also a department </marquee></p></center>
</body>
</html>
[Link]
<html>
<head>
<title>mech</title><link rel="stylesheet" type="text/css" href="[Link]">
<style type="text/css">
p{font-family:Palace Script MT;font-size:55px;text-transform:uppercase;font-
weight:bold;color:blue}
body{background-color:grey}
</style>
</head>
<body>
<marquee><h1>MECANICAL ENGINEERING</h1></marquee>
<p>only boys</p><h2 style=background-color:red;font-family:Pristina;font-size:30px;text-
transform:uppercase>awesome department</h2></body></html>

8
Output

RESULT: Cascading style sheets has been Executed Successfully.

9
Ex No: 3 WEB FORM VALIDATION USING DHTML
Date :

Aim:

To develop a client side scripts for validating web form controls using DHTML.

Algorithm:

1. Start the program


2. Insert <form> element in the HTML document with following attributes:
name attribute:to identify the form element
action attribute : specify the target of the forma data to be submitted
onsubmit: to call the javascript to valid the form when submit button s pressed.
3. Insert all the necessary form elements such as(<fieldset>,<legend>,<input>,<select>,<option>)
4. Insert various types of field such as(text,radio,checkbox,submit)by using “type” attribute of
<input>element
5. Embed validate form() function within the head section of HTML document using
<scipt>element.
6. Validate the input data given and alert the user if the field is blank by using alert()
7. Stop the program.

Program:
[Link]
<html>
<head>
<title>Form validation</title>
<script type="text/javascript">
function validateForm()
{
var x=[Link]
if(x==null || x=="")
{
alert("first name must be filled out");
[Link]();
return false;
}
var x=[Link]
if(x==null ||x =="")
{
alert("last name must be filled out");

10
[Link]();
return false;
}
var z=[Link];
if(z<18||z>60)
{
alert("Please give age range between 18 and 60!");
[Link]();
return false;
}
if(([Link][0].checked==false)&&([Link][1].checked==fals
e))
{
alert("please choose your gender!");
return false;
}
var x=[Link]
if(x==null || x=="")
{
alert("plz provide an email id");
[Link]();
return false;
}
if(![Link](/^[\w]+@[\w]+\.[a-z|A-Z]/))
{
alert("u have entered an invalid email address");
[Link]();
return false;
}
var a=[Link]("cntry");
if([Link]==0)
{
alert("select a country");
[Link]();
return false;
}
if(([Link][0].checked==false)&&
([Link][1].checked==false)&&
([Link][2].checked==false)&&
([Link][3].checked==false)&&
([Link][4].checked==false))
{
alert("please choose ur hobby!");
return false;
11
}
var x=[Link]
if(x=="")
{
alert("Phone number is required field!");
[Link]();
return false;
}
if([Link]!=10)
{
alert("Oops not a 10 digit number");
[Link]();
return false;
}
if([Link](/^\d{10}/))
{
return true;
}
else
{
alert("Invalid character in ur phone no!!! please try again");
[Link]();
return false;
}
}
</script>
</head>
<body style="background-color:pink">
<center><h1 style="color:green">FORM VALIDATION USING JAVASCRIPT</h1></center>
<form name="myForm" action="[Link]" onsubmit="return validateForm();" method="post">
<fieldset>
<legend>Registration Form</legend>
First name:<input type="text" name="fname" placeholder="First Name"><br><br>
Last name:<input type="text" name="lname" placeholder="Last Name"><br><br>
Age<input type="text" name="age" placeholder="ur age"><br><br>

Gender:
<br><input type="radio" name="gender" value="female">female<br><br>
<input type="radio" name="gender" value="male">male<br><br>
Email:<input type="text" name="email" placeholder="Ur Email-Id"><br><br>
Choose ur country:
<select id="cntry" name="country"><br><br>
<option value="0">Select</option>
<option value="1">India</option>
12
<option value="2">Canada</option>
<option value="3">London</option>
</select><br><br>
Hobby:
<input type="checkbox" name="hobby">fishing
<input type="checkbox" name="hobby">gardening
<input type="checkbox" name="hobby">stamp collection
<input type="checkbox" name="hobby">foreign currency collection
<input type="checkbox" name="hobby">reading books<br><br>
Phone no:<input type="text" name="phone" placeholder="Ur contact numbr"><br><br>
<input type="submit" value="submit">
</fieldset>
</form>
</body>
</html>
[Link]
<html>
<head>
<title>Registration Successfull</title>
</head>
<body bgcolor="pink">
<h3><center>Registered Successfully ...... !</center></h3>
</body>
</html>
Output

13
RESULT: Client side scripts for validating web form controls using DHTML has been executed
successfully.

14
Ex No:4 INSTALLATION OF APACHE TOMCAT WEB SERVER
Date:

Aim :
Installation of Apache Tomcat web server.

Procedure:

What is Apache Tomcat

It is an application server or web server or servlet container developed by the Apache Software
Foundation (ASF) and released under the Apache License version 2. HTTP web servers provide an
environment for Java code to run in. It includes tools for configuration and management, but can
also be configured by editing XML configuration files. Most of the modern Java web frameworks
are based on servlets and JavaServer Pages and can run on Apache Tomcat, for example Struts,
JavaServer Faces, Spring, etcetera.

Apache [Link] new released

The Apache Tomcat team has released version 7.0.40 of Apache. They removed several fixes that
stop Tomcat attempting to parse text, improved handling and reporting if a
ConcurrentModificationException occurs while checking for memory leaks, etcetera.

How to Install Tomcat 7

There are certain steps we must follow for configuring Apache Tomcat 7.

Step 1

Download and Install Tomcat

1. Go to [Link] then go to the Binary Distribution/Core/


and download the "zip" package (for example "[Link]", about 8MB).
2. Now unzip the downloaded file into a directory of our choice. Don't unzip onto the dekstop
(since its path is hard to locate). I suggest using "e:\myserver". Tomcat will be unzipped into
the directory "e:\myserver\tomcat-7.0.40".

Step 2
Check the installed directory to ensure it contains the following sub-directories:

 bin folder
 logs folder
 web apps folder

15
 work folder
 temp folder
 conf folder
 lib folder

Step 3
Now, we need to create an Environment Variable JAVA_HOME.

We need to create an environment variable called "JAVA_HOME" and set it to our JDK installed
directory.

1. To create the JAVA_HOME environment variable in Windows XP/Vista/7 we need to push


the "Start" button then select "Control Panel" / "System" / "Advanced system
settings". Then switch to the "Advanced" tab and select "Environment Variables" / "System
Variables" then select "New" (or "Edit" for modification). In "Variable Name", enter
"JAVA_HOME". In "Variable Value", enter your JDK installed directory (e.g., "c:\Program
Files\Java\jdk1.7.0_{xx}").
2. For ensuring that it is set correctly, we need to start a command shell (to refresh the
environment) and issue:
set JAVA_HOME
JAVA_HOME=c:\Program Files\Java\jdk1.7.0_{xx} <== Check that this is OUR JDK
installed directory
3. Sometimes we need to set JRE_HOME also. So for creating JRE_HOME we need to use the
same procedure. Push the "Start" buttonthen select "Control Panel" / "System" / "Advanced
system settings". Then switch to the "Advanced" tab and select "Environment Variables" /
"System Variables" then select "New" (or "Edit" for modification). In "Variable Name",
enter "JRE_HOME". In "Variable Value", enter your JRE installed directory (e.g.,
"C:\Program Files\Java\jre7\").

Step 4
Configure Tomcat Server

The configuration files of the Apache Tomcat Server are located in the "conf" sub-directory of our
Tomcat installed directory, for example "E:\myserver\tomcat7.0.40\conf". There are 4 configuration
XML files:

1. [Link] file
2. [Link] file
3. [Link] file
4. [Link] file

Before proceeding, make a BACKUP of the configuration files.

Step 4(a) "conf\[Link]"; Enabling a Directory Listing

Open the configuration file "[Link]". We shall enable the directory listing by changing "listings"
from "false" to "true" for the "default" servlet.

16
<param-value>true</param-value> like:

Step 4(b) "conf\[Link] file"; set the TCP Port Number


Open the file "[Link]" in a text editor.
The default port number of Tomcat is 8080. Now we need to change the TCP port number for
Tomcat, since the same port number can be used by other servers like SQL Server. We may choose
any number between 1024 and 65535. We shall choose 9999 in this article.

Locate the following lines, and change port="8080" to port="9999". Like:


<Connector port="9999" protocol="HTTP/1.1" Like

Step 4(c) "conf\[Link]"; Enabling Automatic Reload


In that we set reloadable="true" to the <Context> element to enable automatic reload after code
changes.

Add reloadable="true" as in the following:

<Context reloadable="true">
17
......

</Context> Like

Step 4(d) (Optional) "conf\[Link]"

It is used to manage Tomcat by adding the highlighted lines, inside the <tomcat-users> elements.
In that we can add a password and username as an optional step.

Step 5

Now, start the tomcat server

Executable programs and scripts are kept in the "bin" sub-directory of the Tomcat installed
directory, e.g., "E:\myserver\tomcat7.0.40\bin".

Step 5(a) Start Server


Launch a command shell. Set the current directory to "<TOMCAT_HOME>\bin" like
E:\myserver\tomcat7.0.40\bin, and run "[Link]" as follows:

18
After that a new Tomcat console window appears. Read the messages on the console. Look out for
the Tomcat's port number (double check that Tomcat is running on port 9999).......
We saw a figure like:

Step 5(b) Access the Server


Open a browser then enter the URL "[Link] to access the Tomcat server's welcome
page.

If we get this type of page then it means we are done.

19
Now try the URL [Link] to view JSP and servlet examples.
Step 5(c) How to Shutdown Server
We can stop the server using one of the following:

1. Press ctrl-c on the Tomcat console; or


2. Run "<TOMCAT_HOME>\bin\[Link]" script:
// Change the current directory to Tomcat's "bin"
> e: // Change the current drive
e:\> cd E:\myserver\tomcat7.0.40\bin // Change Directory to YOUR Tomcat's "bin"
directory
// Shutdown the server
E:\myserver\tomcat7.0.40\bin> shutdown

RESULT: Installation of Apache Tomcat web server has completed successfully.

20
Ex No:5a INVOKE SERVLETS FROM HTML FORMS
Date :

Aim: To write a program in Java using servlets to invoke servlets from HTML forms.

Algorithm:

Step [Link] a index page , which accepts user name, phone number, gender, address and age as
user input. Invoke the servlet page by submit button trigger.

Step [Link] a servlet called helloservlet which accepts the values given from form and prints
them.

Step [Link] the appropriate files in the following tomcat hierarchy for depolyment

C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\[project-root-


directory]\[Link]

C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\[project-root-directory]\


[Link]

Create two new folders namely WEB-INF within [project-root-directory] folder which has the
[Link] and classes folder within WEB-INF which has .class of the java file

Step 4: Compile the servlet program and create servlet class file , save this class file
into (E:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\webapps\sample\WEB-
INF\classes)classes folder.
Step5: Run the Tomcat server services, call the html file from the browser URL
[Link] and configure [Link] for url link and servlet
name , class link
Step 6: Call the servlet program from html and display the result
Step 7: Stop the services

21
Program
[Link]
<html>
<body>
<form name=f1 action="[Link] method="GET">
USERNAME <input type="text" name="name"><br><br>
PHONE NO <input type="text" name="phno"><br><br>
SEX
<input type="radio" name="sex" value="F">female
<input type="radio" name="sex" value="M">male<br><br>
ADDRESS:<textarea rows="10" cols="10" name="address"></textarea><br><br>
AGE
<select name="age">
<option value="18" > 18 </option>
<option value="19" > 19 </option>
<option value="20" > 20 </option>
<option value="21" > 21 </option>
</select><br></br>
<input type="submit" value="submit">
<input type="button" value="clear">
</form>
</body>
</html>

[Link]
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
public class helloservlet extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res) throws
ServletException,IOException
{
[Link]("text/html");
PrintWriter pw =[Link]();
Enumeration e=[Link]();
while([Link]())
{
String name=(String)[Link]();
String value=[Link](name);
[Link](name+"="+value+"<br>");
}
}
}

22
Output

RESULT: Thus the Java program using servlets to invoke servlets from HTML forms has completed
successfully.

23
Ex No:5b SESSION TRACKING USING HIT COUNT
Date :

Aim: To write a program in java to implement session tracking in servlets using hit count.
.
Algorithm:

Step 1: Write a servlet program with HttpSession object to trcack the session count
Step 2: Compile the servlet program and create servlet class file , save this class file
into(E:\Program Files\Apache Software Foundation\Tomcat
7.0\webapps\sessioncount\WEB- INF\classes) folder.

Step3: Run the Tomcat server services, call theservlet program from the browser
URL ([Link]
and configure [Link] for url link and servlet name , class link

Step 4: Call the servlet program from browser and check the staus of session count
Step 5: Every time visit by client will get increment the session count.
Step 6: Stop the Services.

Program:

SERVLET CODE: [Link]

import [Link].*;
import [Link].*;
import [Link].*;
public class SessionServlet extends HttpServlet
{
protected void processRequest(HttpServletRequest request, HttpServletResponse response)throws
ServletException, IOException
{
[Link]("text/html;charset=UTF-8");
HttpSession sess=[Link]();
PrintWriter out = [Link]();
String head;
Integer cnt=(Integer)[Link]("cnt");
if (cnt==null)
{
cnt=new Integer(0);
head="Welcome You are Accessing the WebPage for the First Time";
}
else
{

24
head="Welcome Once again";
cnt=new Integer([Link]()+1);
}
[Link]("cnt",cnt);
try
{
[Link]("<html>");
[Link]("<head>");
[Link]("<title>Servlet SessionServlet</title>");
[Link]("</head>");
[Link]("<body bgcolor=#FFFF99><br><br><center>");
[Link]("<h1>"+head+"</h1>");
[Link]("<h2>The number of Previous Access="+cnt+"</h2>");
[Link]("</center></body>");
} [Link]("</html>");
finally
{

} [Link]();
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)throws
ServletException, IOException
{
processRequest(request, response);
}
}

[Link]

<?xml version="1.0" encoding="ISO-8859-1"?>


<web-app>
<servlet>
<servlet-name>SessionServlet</servlet-name>
<servlet-class>SessionServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>SessionServlet</servlet-name>
<url-pattern>/SessionServlet</url-pattern>
</servlet-mapping>

</web-app>

25
OUTPUT
Session Servlet Fist time run

Seesion Servlet Multiple time access

RESULT: Thus the Java program to implement session tracking in servlets using hit count has

completed successfully.

26
Ex No:6a ONLINE EXAMINATION USING JSP AND DATABASE
Date :

Aim:. To write programs in Java to create three-tier applications using JSP and Databases for
conducting on-line examination.

Algorithm:

Client:
1. In client side design the contents that you like to transfer to the server
using HTML form with input type tags.
2. In the HTML program the action parameter in the form specifies the name of
the jsp which is to be invoked.
3. The method specified is GET. That means a GET request is made by HTML to the jsp

SERVER:
[Link] [Link].* package which provides the interface for performing simple
input and output programs.
[Link] [Link].* package provides the classes and interfaces for the
operation on databases.
[Link] the name and seatno from the request and calculate the total for the
answers checked by the user in the form.
[Link] the DriverManager class using the following syntax
[Link]("[Link]");
[Link] the DriverManager to connect to the DSN by using the
following syntax
con=[Link]("jdbc:odbc:dsn");
[Link] the Seat_no, Name, Marks of the particular user in the database using
the object of Statement class with insert query.
[Link] the records from the database using the object of ResultSet query.
[Link] close connection to the database by closing the object of connection
class and statement class, Result Set class.

27
Program:
[Link]

<%@ page language="java" import="[Link].*" %>


<%@ page import="[Link].*" %>
<%@ page import="[Link].*" %>
<%
String SeatNum,Name;
String ans1,ans2,ans3,ans4,ans5;
int a1,a2,a3,a4,a5;
a1=a2=a3=a4=a5=0;
Connection connect=null;
Statement stmt=null;
ResultSet rs=null;
[Link]("[Link]");
String url = "jdbc:odbc:StudentDB1";
connect = [Link](url, " ", " ");
if([Link]("action")!=null)
{
SeatNum = [Link]("Seat_no");
Name = [Link]("Name");
ans1 =[Link]("group1");
if([Link]("True"))
a1=2;
else
a1=0;
ans2 = [Link]("group2");
if([Link]("True"))
a2=0;
else
a2=2;
ans3 = [Link]("group3");
if([Link]("True"))
a3=0;
else
a3=2;
ans4 = [Link]("group4");
if([Link]("True"))
a4=2;
else
a4=0;
ans5 = [Link]("group5");
if([Link]("True"))
a5=0;
else
a5=2;
int Total=a1+a2+a3+a4+a5;

28
stmt = [Link]();
String query = "INSERT INTO StudentTable (" + "Seat_no,Name,Marks" + ") VALUES ('"
+SeatNum + "', '" + Name + "', '"+Total+ "')";
int result = [Link](query);
[Link]();
stmt = [Link]();
query = "SELECT * FROM StudentTable WHERE Name="+"'"+Name+"'";
rs = [Link](query);
%>
<html><head><title>Student Mark List</title></head>
<body bgcolor=yellow>
<center>
<h2>Students Marksheet</h2>
<h3>Name of the College:LOYOLA INSTITUTE OF TECHNOLOGY</h3>
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td><b>Seat_No</b></td>
<td><b>Name</b></td>
<td><b>Marks</b></td>
</tr>
<%
while([Link]())
{
%>
<tr>
<td><%=[Link](1)%></td>
<td> <%=[Link](2)%></td>
<td> <%=[Link](3)%></td>
</tr>
<%
}
[Link]();
[Link]();
[Link]();
%>
</table>
</center>
<br/> <br/><br/>
<table>
<tr><td><b>Date:<%=new [Link]().toString() %></td></tr>
<tr><td><b>Signature: X.Y.Z. <b></td></tr>
</table>
<div>
<a href="[Link] here to go back</a>
</body>
</html>
<%}else{%>
<html>
<head><title>Online Examination</title>
<script language="javascript">

29
function validation(Form_obj)
{
if(Form_obj.Seat_no.[Link]==0)
{
alert("Please,fill up the Seat Number");
Form_obj.Seat_no.focus();
return false;
}
if(Form_obj.[Link]==0)
{
alert("Please,fill up the Name");
Form_obj.[Link]();
return false;
}
return true;
}
</script>
</head>
<body bgcolor=pink>
<center>
<h1>OnLine Examination</h1>
</center>
<form action="[Link]" method="post"
name="entry" onSubmit="return validation(this)">
<input type="hidden" value="list" name="action">
<table>
<tr>
<td><h3>Seat Number:</h3></td>
<td><input type="text" name="Seat_no"></td>
</tr>
<tr>
<td><h3>Name:</h3></td>
<td><input type="text" name="Name" size="50"></td>
</tr>
<hr/>
<tr>
<td><b>Total Marks:10(Each question carries equal marks) </b></td>
<td></td><td></td><td></td><td><b>Time: 15 Min.</b></td>
</tr>
</table>
<hr/>
<b>1. Apache is an open source web server</b><br/>
<input type="radio" name="group1" value="True">True
<input type="radio" name="group1" value="False">False<br>
<br/>
<b>2. In Modern PC there is no cache memory.</b><br/>
<input type="radio" name="group2" value="True">True
<input type="radio" name="group2" value="False">False<br>
<br/>
<b>3. Tim-Berner Lee is the originator of Java.</b><br/>
30
<input type="radio" name="group3" value="True">True
<input type="radio" name="group3" value="False">False<br>
<br/>
<b>[Link] is not a video file extension.</b><br/>
<input type="radio" name="group4" value="True">True
<input type="radio" name="group4" value="False">False<br>
<br/>
<b>5. HTTP is a stateful protocol</b><br/>
<input type="radio" name="group5" value="True">True
<input type="radio" name="group5" value="False">False<br>
<hr/>
<center>
<input type = "submit" value="Submit">
<input type = "reset" value="Clear"><br><br>
</center>
</form>
<%}%>
Output:

31
RESULT: Thus the Java program to create three-tier applications using JSP and Databases for
conducting on-line examination has been completed successfully.

32
Ex No: 6b STUDENT INFORMATION SYSTEM USING JSP AND DATABASE
Date :

Aim

To write jsp program to retrieve and display student marklist available in a database.

Algorithm:

Client:
1. In client side design the contents that you like to transfer to the server
using html form with input type tags.
2. In the HTML program the action parameter in the form specifies the name of the jsp
which is to be invoked.
3. The method specified is GET. That means a GET request is made by HTML to the jsp

Server:
1. import [Link].* package which provides the interface for performing simple input and
output programs.
2. import [Link].* package provides the classes and interfaces for the operation on
databases.
3. get the parameters from the request
4. Load the DriverManager class using the following syntax
[Link]("[Link]");
5. Make the DriverManager to connect to the DSN by using the following syntax
con=[Link]("jdbc:odbc:dsn");
6. if the parameter from the request matches with database column then Retrieve the
records of the particular user from the database using the object of ResultSet query.

Program:
[Link]

<%@ page language="java" import="[Link].*" %>


<%@ page import="[Link].*" %>
<%@ page import="[Link].*" %>
<% [Link]("[Link]"); %>
<html>
<head>
<title>Fetching Data From a Database</title>
</head>
<body bgcolor="yellow">

33
<form action="[Link]" method="POST">
<h1 style="color:red">Please enter the register no of student u want to find:</h1>
<input type="text" name="id"><br><br>
<input type="submit" value="Submit">
</form>
<%
Connection connection = [Link]("jdbc:odbc:data", " ", " ");
Statement statement = [Link]();
String id = [Link]("id");
ResultSet resultset = [Link]("select * from stud where Regno =" + id + " ") ;
if(![Link]())
{
[Link]("<h3>"+"Sorry,could not find that student detail!!!!Please try again"+"</h3>");
}
else { %>
<h3 style="color:green">Fetching student detail from a Database </h3>
<table border="1">
<tr style="color:blue">
<th>Regno</th>
<th>Name</th>
<th>Department</th>
<th>Mark1</th>
<th>Mark2</th>
<th>Mark3</th>
</tr>
<tr>
<td> <%= [Link](1) %> </td>
<td> <%= [Link](2) %> </td>
<td> <%= [Link](3) %> </td>
<td> <%= [Link](4) %> </td>
<td> <%= [Link](5) %> </td>
<td> <%= [Link](6) %> </td>
</tr>
</table><br>
<%
}
%>
</body>
</html>

34
Output

35
RESULT: Thus the jsp program to retrieve and display student marklist available in a database
has been completed successfully.

36
Ex No: 7 CREATING WEB PAGES USING XML DOCUMENT
Date :

Aim
To write a program using XML – Schema –XSLT/XSL for displaying the
contents available in XML document

Algorithm:

1. Create an XML document.


2. When developing XML code, include the following line as the first line in the XML file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="[Link]"?>
3. Enclose the coding for this XML file within the
<student></student>tag.
4. Save the XML file using .xml extension.
5. Now create a XSLT file and develop the code with reference to the XML
file [Link] such as
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="[Link]
6. The <xsl : for-each > element can be used to select every XML element of a specified
node-set.
<xsl : for-each select=”Student/Person-Details” > Hence under the root node Student there
are the nodes named Person-Details which get selected each time.

7. The <xsl : value-of> element can be used to extract the value of the desired elementThe
name of the element must be assigned to the select clause.
8. Save the XSLT file using .xsl extension. The XSLT transformation is
done by the browser, when the browser reads the XML file.

Program

[Link]

<?xml version="1.0" encoding="UTF-8"?>


<?xml-stylesheet type="text/xsl" href="[Link]"?>
<student>
<Person-Details>
<name>Aarthi</name>

37
<address>chennai</address>
<std>second</std>
<marks>70 percent</marks>
</Person-Details>
<Person-Details>
<name>priyanka</name>
<address>andhra</address>
<std>second</std>
<marks>80 percent</marks>
</Person-Details>
<Person-Details>
<name>Amni</name>
<address>mumbai</address>
<std>forth</std>
<marks>90 percent</marks>
</Person-Details>
<Person-Details>
<name>Tinu</name>
<address>delhi</address>
<std>tenth</std>
<marks>75 percent</marks>
</Person-Details>
</student>
[Link]
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="[Link]
<xsl:template match="/">
<html>
<body>
<h2>Student database</h2>
<table border="1">
<tr bgcolor="gray">
<th>name</th>
<th>address</th>
<th>standard</th>
<th>marks</th>
</tr>
<xsl:for-each select="student/Person-Details">
<xsl:sort select="marks"/>
<tr bgcolor="pink">
<td><xsl:value-of select="name"/> </td>
<td><xsl:value-of select="address"/></td>
<td><xsl:value-of select="std"/> </td>
<td><xsl:value-of select="marks"/> </td>
</tr>
</xsl:for-each>
</table>
</body>

38
</html>
</xsl:template>
</xsl:stylesheet>

Output

RESULT: Thus the program using XML-Schema- XSLT/XSL for displaying the contents has Executed
Successfully.

39
Ex No: 8a PROGRAM USING DOM PARSER
Date :

Aim:

To write a XML document for checking well formedness of XML document using DOM API

Algorithm:
1. Start the program
2. Import [Link] package for performing simple input and outout operations,[Link].*
package forprocessing the XML documents, [Link]*; package provides the interface for
DOM, [Link].*;provides classes and interface for API for XML(SAX)
3. Read the name of XML document using BufferedReader class.
4. Document BuilderFactory is a factory API an application can obtain parser.
5. Document Builder is used to invoke a method parse.
6. In the try block we are calling the method parse for parsing the XML document. If the XML
document is not well formed then the control of the program will go to catch block.
6. Stop the program.

PROGRAM:
[Link]
import [Link].*;
import [Link].*;
import [Link]*;
import [Link].*;
public class DOM
{
Public static void main(String[] args)throws IOException
{
try
{
[Link](“Enter the name of XML document”);
BufferedReader input=new BufferedReader(new InputStreamReader([Link]));
String file_name=[Link]();
File fp=new file(file_name);
if([Link]())
{
try
{
Document BuilderFactory obj= Document [Link]();
Document Builder builder=[Link] Document Builder();
Input Source src=new Input Source(file_ name);

40
Document doc=[Link](src);
[Link](file_name+”is well-formed”);
}
Catch(Exception e)
{
[Link](file_name+”is not well-formed”);
[Link](1);
}
}
else
{
[Link](“File not found”);
}
}
Catch(IOException e)
{
[Link]();
}
}
}
[Link]
<?xml version=”1.0”?>
<student>
<Rollno>3</Rollno>
<personal_info>
<name>Rohan</name>
<addr>Delhi</addr>
</personal_info>
<sub>English</sub>
<mark>96
</student>

OUTPUT:

javac [Link]
java DOM
Enter the name of XML document
[Link]
[Link] is not a well-formed document

RESULT: Thus the program write a XML document for checking well formedness of XML document using DOM
API has Executed Successfully.

41
Ex No: 8b PROGRAM USING SAX PARSER
Date :

Aim:

To write a XML document for checking well formedness of XML document using SAX API

Algorithm:

1. Start the program


2. Import [Link] package for performing simple input and outout operations,
[Link].*;provides classes and interface for API for XML(SAX), [Link].*;
provides the helper classes for simple API for XML
3. Read the name of XML document using BufferedReader class.
4. XMLReader Factory helps in creating an XML reader,this reader parses xml document..
5. createXMLReader an object reader is created using which we can call a method parse.
6. In the try block we are calling the method parse for parsing the XML document. If the XML
document is not well formed then the control of the program will go to catch block.
6. Stop the program.

PROGRAM:

[Link]
import [Link].*;
import [Link].*;
import [Link].*;

public class SAX


{
Public static void main(String[] args)throws IOException
{
try
{
[Link](“Enter the name of XML document”);
BufferedReader input=new BufferedReader(new InputStreamReader([Link]));
String file_name=[Link]();
File fp=new file(file_name);
if([Link]())
{
try
{
XMLReader reader= XMLReader [Link]();
[Link](file_name);
[Link](file_name+”is well-formed”);
}
Catch(Exception e)

42
{
[Link](file_name+”is not well-formed”);
[Link](1);
}
}
else
{
[Link](“File not found”);
}
}
Catch(IOException e)
{
[Link]();
}
}
}

[Link]

<?xml version=”1.0”?>
<student>
<Rollno>3</Rollno>
<name>Rohan</name>
<addr>Delhi</addr>

</student>

OUTPUT:

javac [Link]
java SAX
Enter the name of XML document
[Link]
[Link] is a well-formed document

RESULT: Thus the program XML document for checking well formedness of XML document using
SAX API has Executed Successfully.

43
Ex No: 9 PROGRAM USING AJAX
Date :

Aim:
To write an AJAX program to retrieve the contents of text file.

Algorithm:
1. 1 A client event is created.
2. Use div section to display information returned from a server.
3. Create button to call a function named loadDoc(), if it is clicked.
4. Add a <script> tag to the page's head section containing the loadDoc() function.
5. Use XMLHttpRequest object to exchange data with a server behind the scenes.
6. Use the open() and send() methods of the XMLHttpRequest object to send a request to a
server.
7. Click the button to view the changes in the browser.

Program
[Link]

<html>
<head>
<script type=”text/javascript”>
function loadDoc()
{
var req;
if ([Link])
{
req=new XMLHttpRequest();
}
else
{
req=new ActiveXObject("[Link]");
}

44
[Link]=function()
{
if ([Link]==4 && [Link]==200)
{
[Link]("myDiv").innerHTML=[Link];
}
}
[Link]("GET","[Link]",true);
[Link]();
}
</script>
</head>
<body>
<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<input type="button" onclick="loadDoc()" value="Change Content">
</body>
</html>

[Link]
AJAX is a technique for creating fast and dynamic web pages.

Output

45
RESULT: Thus the AJAX program to retrieve the contents of text file has Executed Successfully.

46
Ex No: 10
Date: PROJECT WORK ONLINE FLIGHT TICKET RESERVATION

INTRODUCTION:
This is a web application used for booking flight tickets online. It adopts the three-tier
architecture. This application is used by the travel agency to fetch suitable flights for their
customers and helping them book online.

PROJECT DESCRIPTION:
In this web application, the front end application is used by the Customer to provide the
travel details to the travel agency, and the agency in turn searches for the suitable flights available
from the databases of different airlines for the customer available at the back-end. When found, the
agency provides the options (if any), and the customer selects from them. Then the customer is
provided the cost of travel for the selected flight. He then makes payment using the credit card,
where the transactions are recorded in a separate database at the back-end. Then the agency makes
the payment to the respective airlines booking the tickets for the customer.

MINI PROJECT: ONLINE FLIGHT TICKET RESERVATION


[Link]: This is a HTML file which generates the flight reservation form, from the
travel agency.
[Link]: This is a Java Servlet application that interacts with the database to provide customer
with the suitable flight option. And the customer selects an option that is appropriate to his travel
plan.
[Link]: This is also a Java Servlet application that interacts with the database and provides
the cost of travel along with the flight details that has been selected by the customer. And asks for
customer confirmation.
[Link]: This is a HTML page, which gets the payment details from the user like his name,
address, credit card number, etc. and makes the appropriate transactions and updates the
PAYMENT database in the mean while recording the transaction made.
[Link]: This is a Java Servlet page that confirms the transaction made by the customer
and provides the link for the ticket.
[Link]: It is a Java Servlet page which generates the ticket to the user.
[Link]: This is a JavaScript file that is used to perform the validation for the
[Link] page.
[Link]: This is a Cascading StyleSheet file that is used by [Link] and
[Link] files to enhance their presentation.
FLIGHTINFO – TABLE: This table maintains the flight available from different airlines.
PAYMENT – TABLE: This table maintains the customer transaction to the travel agency.
AIRLINE_PAYMENT – TABLE: This table maintains the transactions made between the
airlines and travel agency.

47
PROGRAM:
Reservation [Link]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


<html>
<head>
<title>Bon Voyage Travel Agency</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel = "stylesheet" type = "text/css" href = "[Link]"/>
<script type="text/javascript" src="rform [Link]">
</script>
</head>
<body><br> <br> <br>
<center> <h1 class ="f1"> Bon Voyage Travel Agency </h1> </center><br> <br> <br>
<center> <h1 class="fp1"> <u class="fp3"> Flight Ticket Booking </u> </h1> </center><br><br>
<form name="userapp" action="[Link] onsubmit="return
validateForm();">
<table border="0" cellpadding="1" class="fp1" align="center">
<caption> <u> <b> Select your Travel points </b> </u> </caption>
<tbody><tr>
<td> Source point:</td>
<td><select name="src">
<option value="1"> Chennai </option>
<option value="2"> Bangalore </option>
<option value="3"> Hyderabad </option>
<option value="4"> Goa </option>
<option value="5"> Kolkatta </option>
<option value="6"> Delhi </option>
<option value="7"> Mumbai </option>
</select></td></tr>
<tr>
<td> Destination point:</td>
<td ><select name="dest">
<option value="1"> Chennai </option>
<option value="2"> Bangalore </option>
<option value="3"> Hyderabad </option>
<option value="4"> Goa </option>
<option value="5"> Kolkatta </option>
<option value="6"> Delhi </option>
<option value="7"> Mumbai </option>
</select></td>
</tr> </table><br><br>
<center class="fp1">
<u> <b> Travel Date </b> </u><br>
<select name="sdate">
<option value="1"> 1 </option>
<option value="2"> 2 </option>
<option value="3"> 3 </option>
<option value="4"> 4 </option>
<option value="5"> 5 </option>
48
<option value="6"> 6 </option>
<option value="7"> 7 </option>
<option value="8"> 8 </option>
<option value="9"> 9 </option>
<option value="10"> 10 </option>
<option value="11"> 11 </option>
<option value="12"> 12 </option>
<option value="13"> 13 </option>
<option value="14"> 14 </option>
<option value="15"> 15 </option>
<option value="16"> 16 </option>
<option value="17"> 17 </option>
<option value="18"> 18 </option>
<option value="19"> 19 </option>
<option value="20"> 20 </option>
<option value="21"> 21 </option>
<option value="22"> 22 </option>
<option value="23"> 23 </option>
<option value="24"> 24 </option>
<option value="25"> 25 </option>
<option value="26"> 26 </option>
<option value="27"> 27 </option>
<option value="28"> 28 </option>
<option value="29"> 29 </option>
<option value="30"> 30 </option>
<option value="31"> 31 </option>
</select> <select name="smonth">
<option value="1"> January </option>
<option value="2"> February </option>
<option value="3"> March </option>
<option value="4"> April </option>
<option value="5"> May </option>
<option value="6"> June </option>
<option value="7"> July </option>
<option value="8"> August </option>
<option value="9"> September </option>
<option value="10"> October </option>
<option value="11"> November </option>
<option value="12"> December </option>
</select> <select name="syear">
<option value="2011"> 2011 </option>
<option value="2012"> 2012 </option>
</select> <br> <br> <br>
<u> <b> Choose your class </b> </u><br>
Class:
<select name=ctype>
<option value=1> Business </option>
<option value=2> Economy </option>
</select> </center><br> <br> <br>
<table border="0" cellpadding="1" class="fp1" align="center">
49
caption> <u> <b> Choose No. of seats </b> </u> </caption>
<tbody><tr>
<td> No. of Adults:</td>
<td> <select name="adults">
<option value="0"> 0 </option>
<option value="1"> 1 </option>
<option value="2"> 2 </option>
<option value="3"> 3 </option>
<option value="4"> 4 </option>
<option value="5"> 5 </option>
<option value="6"> 6 </option>
</select></td></tr>
<tr>
<td> No. of Children: </td>
<td><select name="children">
<option value="0"> 0 </option>
<option value="1"> 1 </option>
<option value="2"> 2 </option>
<option value="3"> 3 </option>
<option value="4"> 4 </option>
<option value="5"> 5 </option>
<option value="6"> 6 </option>
</select> </td></tr>
<tr>
<td>No. of Infants:</td>
<td><select name="infants">
<option value="0"> 0 </option>
<option value="1"> 1 </option>
<option value="2"> 2 </option>
<option value="3"> 3 </option>
<option value="4"> 4 </option>
<option value="5"> 5 </option>
<option value="6"> 6 </option>
</select></td></tr>
</tbody>
</table><br><br>
<center> <input type="submit" name="submit">
</center> </form>
</body>
</html>
[Link]:

package agent;
import [Link];
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link];
import [Link].*;
50
public class user extends HttpServlet {
Connection theConnection;
Statement theStatement;
ResultSet theResult;
ServletContext sc= null;
int amount;
public void init() throws ServletException
{
sc = getServletContext();
}
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)throws
ServletException, IOException
{
[Link]("text/html;charset=UTF-8");
PrintWriter out = [Link]();
try {
String src1 = [Link]("src");
String des1 = [Link]("dest");
String classtype = [Link]("ctype");
String adults = [Link]("adults");
String children = [Link]("children");
String infants = [Link]("infants");
String src = null, des = null;
int ctype = [Link](classtype);
int srcpt = [Link](src1);
switch(srcpt)
{
case 1:
src = "Chennai";
break;
case 2:
src = "Bangalore";
break;
case 3:
src = "Hyderabad";
break;
case 4:
src = "Goa";
break;
case 5:
src = "Kolkatta";
break;
case 6:
src = "Delhi";
break;
case 7:
src = "Mumbai";
break;
}

51
int despt = [Link](des1);
switch(despt)
{
case 1:
des = "Chennai";
break;
case 2:
des = "Bangalore";
break;
case 3:
des = "Hyderabad";
break;
case 4:
des = "Goa";
break;
case 5:
des = "Kolkatta";
break;
case 6:
des = "Delhi";
break;
case 7:
des = "Mumbai";
break;
}

[Link]("src",src);
[Link]("des",des);
[Link]("sdate",[Link]("sdate") +"-"+ [Link]("smonth")+"-"+
[Link]("syear"));
[Link]("ctype",classtype);
[Link]("adults",adults);
[Link]("children",children);
[Link]("infants",infants);
[Link]("<html> \n" +
" <head> \n" +
" <title> Choose Your Flight </title> " +
" </head>");
[Link]("<body text = purple>\n <center> ");
[Link]("<form name =user action=[Link] onsubmit
=validate(); >");
[Link]("<table border = 1 width = 40 cellpadding = 5 cellspacing = 5 > <caption> <h1> <u>
Choose Your Flight </h1> </u><br><br><br><br> </caption> <br><br><br><br><br><br> " );
[Link]("<tr>");
[Link]("<th> Flight # </th>");
[Link]("<th> Start Point </th>");
[Link]("<th> Destination </th>");
[Link]("<th> ETD </th>");
[Link]("<th> ETA </th>");
[Link]("<th> Adult Fare </th>");

52
[Link]("<th> Children Fare </th>");
[Link]("<th> Infant Fare </th>");
[Link]("</tr>");
[Link]("[Link]");
theConnection = [Link]("jdbc:odbc:iplab", "system", "newZEPHY6191");
theStatement = [Link]();
theResult = [Link]("select * from flightinfo");
int count=0;
while([Link]())
{
String temp1 = [Link](2);
String temp2 = [Link](3);
if([Link](temp1) && [Link](temp2))
{
count++;
[Link]("<tr>");
String fnum = [Link](1);
[Link](" <td> <input type=radio name=fno value=" + fnum +"> " +fnum+"</td> ");
[Link]("<td>" + temp1 + "</td>");
[Link]("<td>" + temp2 + "</td>");
[Link]("<td>" + [Link](4) + "</td>");
[Link]("<td>" + [Link](5) + "</td>");
if(ctype == 2)
{
[Link]("<td>" + [Link](6) + "</td>");
[Link]("<td>" + [Link](10) + "</td>");
[Link]("<td>" + [Link](11) + "</td>");
}
else if(ctype == 1)
{
[Link]("<td>" + [Link](7) + "</td>");
[Link]("<td>" + [Link](8) + "</td>");
[Link]("<td>" + [Link](9) + "</td>");
}
[Link]("</tr>");
}}
if(count==0)
{
[Link]("<tr>");
[Link](" <td colspan = 12> <center> Sorry! No flights available. . .</center> </td>");
[Link]("</tr>");
}
[Link]("</table> ");
[Link]("<br> <br> <a href= [Link] >
Click here to get back to home page </a> \n <input type = submit value = Submit > \n </center>
\n</form> \n </body> \n </html>");
[Link]();
[Link]();
[Link]();
}

53
catch(Exception e)
{
[Link]();
}
finally
{
[Link]();
}}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)throws
ServletException, IOException {
service(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)throws
ServletException, IOException
{
service(request, response);
}
@Override
public String getServletInfo() {
return "Short description";
}
}
[Link]:
package agent;
import [Link];
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link];
import [Link].*;

public class Payment extends HttpServlet {


Connection theConnection;
Statement theStatement;
ResultSet theResult;
int ctype, adults, children, infants, amount;
ServletContext sc = null;
@Override
public void init() throws ServletException
{
sc = getServletContext();
}
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
[Link]("text/html;charset=UTF-8");

54
PrintWriter out = [Link]();
try {
[Link]("<html> \n " +
" <head> \n" +
" <title> Confirm Details </title>\n" +
" </head>\n");
[Link]("<body text = olive>\n <center> <br> <br> <br> \n ");
String fno = [Link]("fno");
[Link]("fno", [Link]("fno"));
String ct = (String)[Link]("ctype");
String ad = (String)[Link]("adults");
String chd = (String)[Link]("children");
String inft = (String)[Link]("infants");
String fnum = null;
amount = calcPayment(fno, ct, ad, chd, inft);
String amt = "Amount: "+amount;
[Link]("amt", amt);
[Link]("[Link]");
theConnection = [Link]("jdbc:odbc:iplab", "system", "newZEPHY6191");
theStatement = [Link]();
theResult = [Link]("select * from flightinfo;");
while([Link]())
{
fnum = [Link](1);
if([Link](fnum))
{
[Link]("<h1> <u> Your Ticket Details </u> </h1>");
[Link](" <br> <br> Flight Number: "+ fnum );
[Link](" <br>Start Point: "+[Link](2) );
[Link](" <br>Destination Point: "+[Link](3) );
[Link](" <br>ETD: "+[Link](4) );
[Link](" <br>ETA: "+[Link](5) );
if(ctype == 2)
{
[Link](" <br> Economy Adult Fare: "+[Link](7)+ "\t No. of adults booked:"+
adults);
[Link](" <br> Economy Children Fare: "+[Link](8)+ "\t No. of children
booked:"+ children );
[Link](" <br> Economy Infant Fare: "+[Link](9)+ "\t No. of infants booked:"+
infants );
}
else if(ctype == 1)
{
[Link](" <br>Business Adult Fare: "+[Link](6)+ "\t No. of adults booked:"+
adults );
[Link](" <br>Business Children Fare: "+[Link](10)+ "\t No. of children booked:"+
children );
[Link](" <br>Business Infant Fare: "+[Link](11)+ "\t No. of infants booked:"+
infants );
}

55
[Link]("<br> <br> <b> The total Ticket price: "+amount+ "</b>");
}
}
[Link]( "<br> <br> <br> <br> <a
href=[Link] > Not Satisfied! Click here to
move back and make another selection <a> ");
[Link]( "<br> <br> <br> <br> <a href=[Link] >
Yup! Satisfied! Lemme make the payment! <a> ");
[Link](" </body> \n </html>");
[Link]();
[Link]();
[Link]();
}
catch(Exception e)
{
[Link]();
}
finally {
[Link]();
}
}
public int calcPayment(String fno, String ct, String ad, String chd, String inft)
{
int amt = 0;
try {
ctype = [Link](ct);
adults = [Link](ad);
children = [Link](chd);
infants = [Link](inft);
[Link]("[Link]");
theConnection = [Link]("jdbc:odbc:iplab", "system", "newZEPHY6191");
theStatement = [Link]();
theResult = [Link]("select * from flightinfo;" );
while([Link]())
{
String fnum = [Link](1);
if([Link](fnum))
{
if(ctype == 2)
amt = (adults * [Link]([Link](6))) + (children *
[Link]([Link](10))) + (infants * [Link]([Link](11)));
else if (ctype == 1)
amt = (adults * [Link]([Link](7))) + (children *
[Link]([Link](8))) + (infants * [Link]([Link](9)));
}
}
[Link]();
[Link]();
[Link]();
}

56
catch(Exception e)
{
[Link]();
}
return amt;
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)throws
ServletException, IOException {service(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)throws
ServletException, IOException {service(request, response);
}
@Override
public String getServletInfo() {
return "Short description";
}
}

[Link]
<html>
<head>
<title>Make your Payment</title>
<link rel = "stylesheet" type = "text/css" href = "[Link]"/>
<script type="text/javascript">
function validateForm()
{
var name =[Link];
if ([Link] == 0 || name==null)
{
alert("Passenger name must be filled out!");
return false;
}
var type = [Link][[Link]].value
if (type==null)
{
alert("Please select the Lead passenger type!");
return false;
}
var addr = [Link];
if([Link]==0 || addr==null )
{
alert("Passenger address must be filled out!");
return false;
}
var pvalid = "0123456789";
var phone=[Link]
if(phone=="")
{

57
alert("Phone number is a required field!"); return false;
}
if([Link] != 10)
{
alert("Invalid phone number! Please try again.");
return false;
}
for (var i=0; i < [Link]; i++)
{
temp = "" + [Link](i, i+1);
if ([Link](temp) == "-1")
{
alert("Invalid characters in your phone. Please try again.");
return false;
}
}
var ctype= [Link][[Link]].value
if (ctype==null)
{
alert("Please select the Card type!");
return false;
}
var cvalid = "0123456789";
var cno=[Link]
if(cno=="")
{
alert("Card number is a required field!");
return false;
}
if([Link] != 16)
{
alert("Invalid card number! Please try again.");
return false;
}
for (i=0; i < [Link]; i++)
{
temp = "" + [Link](i, i+1);
if ([Link](temp) == "-1")
{
alert("Invalid characters in your card number field. Please try again.");
return false;
}
}
var vdt =[Link]
if (vdt==null || vdt=="")
{
alert("Card validity date must be filled out");
return false;
}

58
var edt =[Link]
if (edt==null || edt=="")
{
alert("Card expiry date must be filled out");
return false;
}
var pinno = [Link];
var svalid = "0123456789";
if(pinno=="")
{
alert("PIN is a required field!");
return false;
}
if([Link] != 4)
{
alert("Invalid PIN! Please try again.");
return false;
}
for (i=0; i < [Link]; i++)
{
temp = "" + [Link](i, i+1);
if ([Link](temp) == "-1")
{
alert("Invalid characters in your PIN field. Please try again.");
return false;
}
}
}
</script>
</head>
<body>
<br> <br> <br> <h1 class ="m1"> Make Payment </h1> <br> <br> <br>
<form name = "passenger" action = "[Link] onsubmit=
"return validateForm();">
<table border="0" align="center" class="mp1">
<tr>
<td>Lead Passenger Name: </td>
<td> <input type = text name = pname> </td> </tr>
<tr> <td> Lead Passenger Type: </td>
<td> <select name = ptype>
<option value = 1> Adult </option>
<option value = 2> Child </option>
<option value = 3> Infant </option>
</select> </td> </tr>
<tr>
<td> Address: </td>
<td> <input type = textarea name = addr> </td> </tr>
<tr> <td> Phone: </td> <td> <input type = text name = phone> </td>
</tr>
<tr> <td> Card Type: </td> <td> <select name = ctype>

59
<option value = 1> Visa </option>
<option value = 2> Master Card </option>
</select> </td>
</tr>
<tr> <td>
Card Number: </td> <td> <input type = text name = cnum> </td></tr>
<tr> <td>Validity date: </td> <td> <input type = text name = vdate> </td></tr>
<tr> <td>Expiry date: </td> <td> <input type = text name = edate> </td></tr>
<tr> <td> PIN: </td> <td> <input type = text name = pin> </td></tr> </table><br> <br>
<center><input type = submit value = submit></center>
</form>
</body>
</html>

[Link]
package agent;
import [Link];
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link];
import [Link].*;
public class Passenger extends HttpServlet
{
Connection theConnection;
Statement theStatement;
ResultSet theResult;
String agency = "Bon Voyage Travel Agency" ;
String branch = "Chennai";
ServletContext sc ;
int res;
@Override
public void init()
{
sc = getServletContext();
}
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
[Link]("text/html;charset=UTF-8");
PrintWriter out = [Link]();
Try
{
String pname = [Link]("pname");
String ptype = [Link]("ptype");
String addr = [Link]("addr");
String phone = [Link]("phone");
String ctype = [Link]("ctype");

60
String cnum = [Link]("cnum");
String vdate = [Link]("vdate");
String edate = [Link]("edate");
String pin = [Link]("pin");
String amt = (String)[Link]("amt");
String fno = (String) [Link]("fno");
String amount = [Link](8);
[Link]("pname",pname);
[Link]("ptype",ptype);
[Link]("addr",addr);
[Link]("phone",phone);
[Link]("[Link]");
theConnection = [Link]("jdbc:odbc:iplab", "system", "newZEPHY6191");
theStatement = [Link]();
res = [Link]("INSERT INTO PAYMENT(PNAME, PTYPE, PADDR,
PPHONE, CARDTYPE, CARDNO, VALIDFROM, EXPIRYDATE,PIN,AMT) VALUES
(\'"+pname+"\' ,\'"+ptype+"\' ,\' "+addr+"\' ,\' "+phone+"\' ,\' "+ctype+"\' ,\' "+cnum+"\' ,\'
"+vdate+"\' ,\' "+edate+"\' ,\' "+pin+"\' ,\' "+amount +"\' ); " ) ;
res = [Link]("INSERT INTO AIRLINE_PAYMENT(AGENCYNAME,
BRANCH, PASSENGERNAME, FLIGHTNO, AMOUNT) VALUES (\'"+agency+"\'
,\'"+branch+"\' ,\' "+pname+"\' ,\' "+fno+"\' ,\' "+amount+"\' ); " ) ;
[Link]("<html>");
[Link]("<head>");
[Link]("<title>Make your Payment</title>");
[Link]("</head>");
[Link]("<body text = teal> <br> <br> <br> <br> <br> <br> ");
[Link]("<CENTER> <H1> <B> <br> <br> <br> Thanks for using our service!</B> </H1>
<br> <br> <br> </CENTER>");
[Link]("<center> <a href= [Link] > Click here to get
your Tickets </a> </center>");
[Link]("<br> <br> <br> Please do take up a hard copy of the ticket which is to be generated.");
[Link]("</body>");
[Link]("</html>");
}
catch(Exception e)
{
[Link](e);
}
finally
{
[Link]();
}
}
}

[Link]
package agent;
import [Link];
import [Link];
import [Link].*;
61
import [Link];
import [Link];
import [Link];
import [Link].*;
public class ticket extends HttpServlet {
Connection theConnection;
Statement theStatement;
ResultSet theResult;
ServletContext sc;
@Override
public void init()
{
sc = getServletContext();
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response)throws
ServletException, IOException
{
[Link]("text/html;charset=UTF-8");
PrintWriter out = [Link]();
String pname = (String)[Link]("pname");
String ptype = (String)[Link]("ptype");
String addr = (String)[Link]("addr");
String phone = (String)[Link]("phone");
String adults = (String)[Link]("adults");
String children = (String)[Link]("children");
String infants = (String)[Link]("infants");
String ctype = (String)[Link]("ctype");
String src = (String)[Link]("src");
String des = (String)[Link]("des");
String fno = (String)[Link]("fno");
String tdate = (String)[Link]("sdate");
String amt = (String)[Link]("amt");
try {
[Link]("[Link]");
[Link]("<html>");
[Link]("<head>");
[Link]("<title>Your Ticket</title>");
[Link]("</head>");
[Link]("<body bgcolor = MAROON text = BLACK > <br> <br> <br> <B> ");
[Link]("<table border=0 align = center> <caption> <h1> <CENTER> <B> THE INDIAN </B>
</CENTER> </h1></caption> ");
[Link]("<tr> <td rowspan = 15> <img src=./[Link] width=180 height=400> </td> <td>
Lead Passenger Name: </td> <td> "+pname+" </td> </tr>");
[Link](" <tr> ");
[Link](" <td>Lead Passenger Type: </td> <td> "+ptype+"</td> </tr>");
[Link]("<tr> <td>Lead Passenger Address:</td> <td> "+addr+"</td> </tr>");
[Link]("<tr> <td>Lead Passenger Phone Number:</td> <td> "+phone+"</td> </tr>");
[Link]("<tr> <td>No. of Adults:</td> <td> "+adults+"</td> </tr>");
[Link]("<tr> <td>No. of Children:</td> <td> "+children+"</td> </tr>");
[Link]("<tr> <td>No. of Infants:</td> <td> "+infants+"</td> </tr>");

62
[Link]("<tr> <td>Class: </td> <td>"+ctype+"</td> </tr>");
[Link]("<tr> <td>Starting Point:</td> <td> "+src+"</td> </tr>");
[Link]("<tr> <td>Destination Point:</td> <td> "+des+"</td> </tr>");
[Link]("<tr> <td>Flight No.:</td> <td> "+fno+"</td> </tr>");
[Link]("<tr> <td>Travel Date:</td> <td> "+tdate+"</td> </tr>");
[Link]("<tr> <td colspan = 2> Total "+amt+"</td> </tr> </table> </B>");
[Link]("<center> This is an e-ticket. This is a computer generated copy and does not required to
be signatured. </center>");
[Link]("</body>");
[Link]("</html>");
}
catch(Exception e)
{
[Link](e);
}
finally {
[Link]();
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)throws
ServletException, IOException
{
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)throws
ServletException, IOException
{
processRequest(request, response);
}
@Override
public String getServletInfo() {
return "Short description";
}
}
[Link]
function validateForm()
{
var src = [Link][[Link]].value
var dest = [Link][[Link]].value
var d = [Link][[Link]].value
var m = [Link][[Link]].value
var y = [Link][[Link]].value
var a = [Link][[Link]].value
var c = [Link][[Link]].value
var i = [Link][[Link]].value
var dt = new Date();
var cd = [Link]();
var cm = [Link]();

63
var cy =
[Link]();
//VALIDATE SRC AND DES POINTS
if (src == dest)
{
alert("Src and destination cannot be the same!");
return false;
}
//VALIDATE TRAVEL DATE
if(y==cy)
{
if((m<=cm & d<cd) )
{
alert("Enter a Valid date!");
return false;
}
}
if(((m==2)&(d>29)) | ((m==4)&(d>30)) | ((m==6)&(d>30)) | ((m==9)&(d>30)) |
((m==11)&(d>30))) {
alert("Enter a Valid date!");
return false;
}
//VALIDATE NO. OF SEATS
if((a==0) & (c==0) & (i==0))
{
alert("Enter Correct number of passengers!");
return false;
}
}

[Link]

.f1 {
color: #6666ff;
font-family: Verdana,Arial,Helvetica,sans-serif;
background-color: white;
text-align: center;
vertical-align: middle;
line-height: normal;
border-right-style: outset;
border-left-style: outset;
border-bottom-style: outset;
border-top-style: outset;
border-right-color: #6666ff;
border-left-color: #6666ff;
border-bottom-color: #6666ff;
border-top-color: #6666ff;
font-size: 18px;
text-decoration: underline;
font-style: italic;
64
font-weight: bold;
}
.fp1
{
color: #6666ff;
font-family: serif;
background-color: white;
text-align: center;
vertical-align: middle;
line-height: normal;
font-size: 18px;
}
.fp2
{
text-align: center;
vertical-align: super;
}
.fp3
{
font-size: XX-large;
}
.m1
{
color:maroon;
font-family: Verdana,Arial,Helvetica,sans-serif;
background-color: white;
text-align: center;
vertical-align: middle;
line-height: normal;
border-right-style: outset;
border-left-style: outset;
border-bottom-style: outset;
border-top-style: outset;
border-right-color: maroon;
border-left-color: maroon;
border-bottom-color: maroon;
border-top-color: maroon;
font-size: 18px;
text-decoration: underline;
font-style: italic;
font-weight: bold;
}
.mp1
{
color: maroon;
font-family: serif;
background-color: white;
text-align: center;
vertical-align: middle;
line-height: normal;
font-size: 18px;
65
}
.u1
{
color: green;
font-weight: bold;
font-style: italic;
text-decoration: underline;
font-size: XX-large;
font-family: sans-serif;
border-right-color: purple;
border-left-color: purple;
border-bottom-color: purple;
border-top-color: purple;
background-image: url(../[Link]);
background-position: top center;
}

DATABASE – TABLES:

1. Table Name: FLIGHT INFO

2. Table Name: Payment

66
3. Table Name: Airline_payment

OUTPUT:

[Link]:

67
[Link]:

[Link]:

[Link]:

68
[Link]:

[Link]:

RESULT: The web application for flight ticket Reservation has been executed successfully.

69

You might also like