WT Lab
WT Lab
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
CERTFICATE
External Examiner
INDEX
S.NO NAME OF THE PROGRAM PAGE
NO
1 Develop and demonstrate a HTML document that illustrates the
use external style sheet, ordered list, table, borders, padding, color,
and the <span> tag.
2 Write HTML code to provide intra document linking.
3 Create a form with the following specifications :
a). Our form uses frames, one to hold the links bar at the top of the
browser window.
b). Other is a larger frame that provides the main view.
c). The links bar should contain 3 links, which when clicked,
should display the appropriate HTML file in the larger frame.
4 To Create a webpage with the following using html
a. To embed an image in web page
b. To fix the hot spots
c. Show all the related information when a hot spot is clicked in the
map.
5 Develop a HTML Form,which accepts any Mathematical
expression. Write JavaScript code to Evaluates the expression and
Displays the result
6 Create a HTML form that has number of Textboxes. When the
form runs in the Browser fill the textboxes with data. Write
JavaScript code that verifies that all textboxes has been filled. If a
textboxes has been left empty, popup an alert indicating which
textbox has been left empty
7 Write a JavaScript code to find the sum of N natural Numbers.(Use
user-defined function)
8 Write a JavaScript code to find factorial of N. (Use Recursive
Function)
10 Create a web page using two image files, which switch between
one another as the mouse pointer moves over the images. Use the
onMouseOver and onMouseOut event handlers.
11 Design an XML document to store information about a student in
an engineering college affiliated to ANU. The information must
include college id, Name of the College, Brach, Year of Joining,
and e-mail id. Make up sample data for 3 students. Create a CSS
style sheet and use it to display the document.
12 Create an XML document, which contains 10 users information.
Implement a program, which takes User Id as an input and returns
the user details by taking the user information from the XML
document.
13 Write a program for implementing student information using xml.
14 Write a java program to illustrate java to database connectivity
using JDBC
1a.html :
<html>
<head>
<link rel="stylesheet" type="text/css" href="1b.css"/>
<title>Lab Program1</title>
</head>
<body id="div">
<h1>This header is 50 pt</h1>
<h1>This header is green</h1>
<p>This paragraph has a left margin of 60 pixels</p>
<table cellpadding="20" border="1" width="7%"><!-- table with name & email
-->
<tr>
<th width="210">Name</th>
<th>Email</th>
<th>Mobile</th>
</tr>
<tr>
<td width="210">Mahendra</td>
<td>paladugu.mahendra@gmail.com</td>
<td>8712345927</td>
</tr>
<tr>
<td width="210">Surendra</td>
<td>surendrasuri45@rediffmail.com</td>
<td>8500245229</td>
</tr>
<tr>
<td width="210">Ram Mohan</td>
<td>yanumularammohan661@yahoo.com</td>
<td>8500614589</td>
</tr>
</table>
<hr><!--horizontal line -->
<ol><!--ordered list-->
<li>Mahendra</li>
<li>Surendra</li>
<li>Mohan</li>
</ol>
<p>
<span>This is a text.</span>This is a text. This is a text. This is a text. This is a
text. This is a text. This is a text.
This is a text. This is a text. <span>This is a text.</span>
</p>
</body>
</html>
1b.css :
#tablediv{ color:Aqua;
background-color:green;
}
Output :
Output :
3. Create a form with the following specifications :
a). Our form uses frames, one to hold the links bar at the top of the
browser window.
b). Other is a larger frame that provides the main view.
c). The links bar should contain 5 links, which when clicked, should
display the appropriate HTML file in the larger frame.
framedemo.html :
<frameset rows="25%,75%">
<frame src=logo.html scrolling=no resize frameborder=0>
<frameset cols="10%,90%">
<frame src=lang.html noresizeframeborder=0>
<frame src=aboutme.html name=f frameborder=0>
</frameset>
</frameset>
aboutme.html :
<html>
<body background="bkgnd2.jpg" text=Aqua>
<table border=0 width=40% color=Aqua align=left
<tr>
<td colspan=2>
<h1><center><font color=green>About Me</h1></center></font></td>
</tr>
<tr>
<td width=16%><imgsrc="mahilogo2.jpg"></td>
<td><font color=black><b>P.MahendraBabu<br>
STUDENT<br>
Department of Computer Science and Engineering,<br>
Acharya Nagarjuna University,<br>
Nagarjuna Nagar, Guntur.<br>
Phone : 8712345927<br>
E-mail: paladugu.mahendra@gmail.com<br></b></font>
</td>
</tr>
</table>
</body>
</html>
logo.html :
<html>
<body bgcolor=#8080ff>
<table border=0 width=100%>
<tr>
<td rowspan=2 width=8%><imgsrc="bkgnd1.jpg" width=150 height=150></td>
<td><font size=8 color=navy><b><center>Mahendra InfoTech</font></b><br>
<font color=darkred size=5><b>A Complete reference of
Technology</font></b></td>
</tr>
<tr>
<td><marquee behavior=alternate direction=left><h2><font color=yellow>The
inexhaustible
vessel</font></h2></marquee><br></center></td>
</tr>
</table>
</body>
</html>
lang.html :
<html>
<head>
<title>Welcome</title>
</head>
<body bgcolor=peachpuff text=maroon>
<h3><a href="c.html" target=f>C</a></h3>
<h3><a href="cpp.html" target=f>C++</a></h3>
<h3><a href="java.html" target=f>JAVA</a></h3>
<h3><a href="ht.html" target=f>HTML</a></h3>
<h3><a href="jsct.html" target=f>JavaScript</a></h3>
<h3><a href="aboutme.html" target=f>Home</a></h3>
</body>
</html>
java.html :
<html>
<head>
<title> Java </title>
</head>
<body text=navy>
<h1><center>Java</h1></center>
<hr>
<a name=home></a>
<ul>
<li><a href="#intro">Introduction</a></li>
<li><a href="#hist">History</a></li>
<li><a href="#Feat">Java Features</a></li>
<li><a href="#dt">Datatypes</a></li>
</ul>
<hr>
<b><a name="intro">INTRODUCTION</a></b>
<p>
Java is a platform independent, object oriented programming language, which is
used to develop different types of applications like:
<ul>
<li>Desktop Applications</li>
<li>Web Applications</li>
<li>Enterprise Applications</li>
<li>Mobile Applications</li>
<li>Applications for Embedded Systems</li>
<li>Applications for Smart Card</li>
<li>Applications for Robotics</li>
<li>And Many more....</li>
</ul>
</p>
<b><a name="hist">HISTORY</a></b>
<li>1.In 1991,a small group of Sun engineers (James Gosling,Mike Sheridan, and
Patrick Naughton)called "Green Team"led by James Gosling invented Java.</li>
<li>2. The initial name of java is "oak".</li>
<li>3.On January 27,2010 Java was merged into the Oracle Corporation.</li>
</ul>
<b><a name="Feat">Java Features</a></b>
<ul>
<li>1.Compiled and Interpreted Programming Language</li>
<li>2.Platform Inedpendence</li>
<li>3.Object Oriented</li>
<li>4.Distributed and Network Supported</li>
<li>5.Robust</li>
</ul>
<b><a name="dt">Datatypes</a></b>
<p>
<ul>
<li>Primitive Datatypes</li>
<li>Reference\Object Datatypes</li>
</ul>
</p>
<br><br><b><a href="#home">Top</a></b>
</body>
</html>
ht.html :
<html>
<head>
<body bgcolor=#00ffff text=blue>
<center><h1>HTML</h1></center>
<p>
<ul>
<li>HTML stands for "Hyper Text Mark-up Language"</li>
<li>HTML is the bricks and mortar of the WWW.</li>
<li>Without HTML the World Wide Web could not have become as important as
it is today.</li>
<li>HTML is a document formatting language common the all computerso the
WWW.</li>
<li>HTML permits cross platform communication between
Macs,Apples,SUNs,PCs and others to view a document in a similar way.</li>
<li>HTML has two sections, the "Head" section and the "Body" section</li>
</ul>
</p>
</body>
</html>
Output :
4. To Create a webpage with the following using html
a. To embed an image in web page
b. To fix the hot spots
c. Show all the related information when a hot spot is clicked in the map.
Image.html:
<html>
<head>
<title>
<title>Image Map</title>
</head>
<body><imgsrc="Andhramap.jpg" usemap="#Andhramap" alt="Andhrmap">
<map name="Andhramap">
<area href="Prakasam.html" alt="Prakasam"shape="circle" coords="50,180,120"
title="Prakasam"/>
<area href="Guntur.html" shape="square" coords="" title="Guntur/">
</map>
</body>
</html>
Prakasam.html:
<html>
<head>
<title>About Prakasam</title>
</head>
<body>
<center><h1>Prakasam</h1></center>
<hr>
<ul>
<li>Area : 17,626 Sq.Kms.</li>
<li>Population : 3,397,448</li>
<li>Collector Name : Smt. Sujatha Sharma I.A.S</li>
<li>Mandals : 24 </li>
</ul>
</hr>
<a href="imagemap.html">Andhramap</a>
</body>
</html>
Output:
5. Develop a HTML Form,which accepts any Mathematical expression. Write
JavaScript code to Evaluates the expression and Displays the result.
<html>
<head>
<title>Mathematical Expression</title>
<script type="text/javascript">
function math_exp()
{
var x=document.form1.exptext.value;
var result=eval(x);
document.form1.resulttext.value=result;
}
</script>
</head>
<body>
<form name="form1">
<table>
<tr>
<td>Expression</td>
<td><input type="text" name="exptext"/></td>
</tr>
<tr>
<td>Result</td>
<td><input type="text" name="resulttext"/></td>
</tr>
<tr>
<td><input type="button" value="calculate" onclick="math_exp()"/></td>
</tr>
</table>
</form>
</body>
</html>
Output :
6. Create a HTML form that has number of Textboxes. When the form runs
in the Browser fill the textboxes with data. Write JavaScript code that verifies
that all textboxes has been filled. If a textboxes has been left empty, popup an
alert indicating which textbox has been left empty.
<html>
<head>
<title>Registration Form</title>
<script type="text/javascript">
function validate()
{
if(document.myForm.Name.value=="")
{
alert("Please Provide Your Name");
document.myForm.Name.focus();
return false;
}
if(document.myForm.Email.value=="")
{
alert("Please Provide Your Email ID");
document.myForm.Email.focus();
return false;
}
if((document.myform.Zip.value=="")||(document.myForm.Zip.value.length!
=5))
{
alert("Please Provide a valid zip code format #####");
document.myForm.Zip.focus();
return false;
}
if(document.myForm.Country.value=="-1")
{
alert("Please Provide Your Country Name");
return false;
}
return true;
}
function validateEmail()
{
varemailID=document.myForm.Email.value;
atpos=emailId.indexOf("@");
dotpos=emailID.lastIndexOf(".");
if(atpos<1||(dotpos-atpos<2))
{
alert("Please Enter Correct Email ID");
document.myForm.Email.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<form name="myForm" onsubmit="return(validate());">
<table cellspacing="2" cellpadding="2" border="1">
<tr>
<td>Name</td>
<td><input type="text" name="Email" onchange="validateEmail();"/></td>
</tr>
<tr>
<td>Zip Code</td>
<td><input type="text" name="Zip"/></td>
</tr>
<tr>
<td>Country</td>
<td><select name="Country">
<option value="-1" selected>[Choose Yours]</option>
<option value="1">INDIA</option>
<option value="2">USA</option>
<option value="3">Srilanka</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="submit"/></td>
</tr>
</table>
</form>
</body>
</html>
Output :
7. Write a JavaScript code to find the sum of N natural Numbers.(Use user-
defined function)
<html>
<head>
<script type="text/javascript">
varnum=window.prompt("Enter the number:","");
var n=parseInt(num);
result=sumnaturalno(n);
window.alert("The sum of "+n+"natural number is"+result);
function sumnaturalno(n)
{
vari;
var sum=0;
for(i=1;i<=n;i++)
{
sum=sum+i;
}
return(sum);
}
</script>
</head>
</html>
Output :
8. Write a JavaScript code to find factorial of N. (Use Recursive Function)
<html>
<body>
<script type="text/javascript">
var n=parseInt(window.prompt("Enter the Number:"));
var result=fact(n);
window.alert("Factorial of the given number"+result);
function fact(n)
{
if(n==0)
return 1;
else
return(n*fact(n-1));
}
</script>
</body>
</html>
Output :
9. Write a JavaScript code block using arrays and generates the current date
in words, this should include the day, month and year.
<html>
<head>
<script type="text/javascript">
var d=new Date();
var weekday=new
Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturda
y");
varmonthname=new
Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec
");
document.write(weekday[d.getDay()]+"");
document.write(d.getDate()+".");
document.write(monthname[d.getMonth()]+"");
document.write(d.getFullYear());
</script>
</head>
<body>
</body>
</html>
Output :
10. Create a web page using two image files, which switch between one
another as the mouse pointer moves over the images. Use the onMouseOver
and onMouseOut event handlers.
<html>
<head>
<script type="text/javascript">
function mouseover()
{
document.getElementById("img").src="img.jpg";
}
function mouseout()
{
document.getElementById("img").src=img1.jpg;
}
</script>
</head>
<body>
<imgsrc="img2.jpg" id="img" onmouseover="mouseover()"
onmouseout="mouseout()"/>
</body>
</html>
Output :
11. Design an XML document to store information about a student in an
engineering college affiliated to ANU. The information must include college
id, Name of the College, Brach, Year of Joining, and e-mail id. Make up
sample data for 3 students. Create a CSS style sheet and use it to display the
document.
XML FILE
4a.CSS
student {margin-top:15px;font-weight:bold;color:black;}
info {display:block;margin-left:15px;color:gray;}
usn, name {color:red;font-size:15pt;}
coll, branch {color:blue;font-size:15pt;}
yoj, email {color:green;font-size:15pt;}
output:
12. Create an XML document, which contains 10 users information.
Implement a program, which takes User Id as an input and returns the user
details by taking the user information from the XML document.
Info.xml
<document>
<users>
<user>
<userid>abc</userid>
<password>abc</password>
<first_name>raj</first_name>
<last_name>kumar</last_name>
<dob>10/1/1982</dob>
</user>
<user>
<userid>ravi</userid>
<password>ravi</password>
<first_name>ravi</first_name>
<last_name>kumar</last_name>
<dob>11/11/1982</dob>
</user>
<user>
<userid>sri</userid>
<password>sri</password>
<first_name>sri</first_name>
<last_name>ram</last_name>
<dob>12/12/1983</dob>
</user>
<user>
<userid>lax</userid>
<password>lax</password>
<first_name>laxman</first_name>
<last_name>kumar</last_name>
<dob>1/1/1980</dob>
</user>
<user>
<userid>chandu</userid>
<password>chandu</password>
<first_name>chandana</first_name>
<last_name>priya</last_name>
<dob>9/11/1998</dob>
</user>
<user>
<userid>vysu</userid>
<password>vysu</password>
<first_name>vyshnavi</first_name>
<last_name>matha</last_name>
<dob>17/6/1982</dob>
</user>
<user>
<userid>prem</userid>
<password>prem</password>
<first_name>prem</first_name>
<last_name>kumar</last_name>
<dob>11/11/1988</dob>
</user>
<user>
<userid>geeta</userid>
<password>geeta</password>
<first_name>geeta</first_name>
<last_name>anjali</last_name>
<dob>13/1/1972</dob>
</user>
<user>
<userid>preeti</userid>
<password>preeti</password>
<first_name>prethi</first_name>
<last_name>priya</last_name>
<dob>7/11/1968</dob>
</user>
<user>
<userid>praveen</userid>
<password>praveen</password>
<first_name>kumar</first_name>
<last_name>kumar</last_name>
<dob>11/11/1999</dob>
</user>
</users>
</document>
Program:
<html>
<head>
<title>authorization page</title>
varxmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.load("C:\Users\satishpolampalli\Desktop\New folder\info.xml");
function search()
var id=document.myform.id.value;
varpword=document.myform.pword.value;
varqry=xmlDoc.selectNodes("document/users/user[userid='"+id+"']");
if(qry.length!=0)
if(pword!=qry.item(0).childNodes.item(1).text)
document.body.innerHTML="Password incorrect";
document.write("success");
else
</script>
</head>
<body>
<pre>
<center>
</form>
</center>
</pre>
</body>
</html>
Output:
13. Write a program for implementing student information using xml.
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="i.css"?>
<document>
<student>
<name>Mahendra</name>
<addr>6-1 Kanigiri</addr>
<grade>A</grade>
</student>
<student>
<name>Suraj</name>
<addr>1-1 Kanigiri</addr>
<grade>A</grade>
</student>
<student>
<name>Sarat</name>
<addr>2-1 Kanigiri</addr>
<grade> A </grade>
</student>
</document>
i.css;
student{ font-family:arial;
color: Green;
font-size: 20pt;
}
Output:
14. Write a java program to illustrate java to database connectivity using
JDBC.
import java.sql.*;
import static java.lang.System.*;
class Select2
{ public static void main(String args[])throws Exception
{ Class.forName("oracle.jdbc.driver.OracleDriver");
out.println("Loaded....");
Connection
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL","sc
ott","tiger");
out.println("Connected...");
Statement stmt=con.createStatement();
ResultSetrs=stmt.executeQuery("select * from emp");
while(rs.next())
{ out.print(rs.getString("empno")+"\t"+rs.getString("ename"));
out.println();
}
con.close();
}
}
OUTPUT:
empno ename
1 Mahendra
2 Surendra
3 Suraj
15. Write a program to print the Fibonacci numbers using RMI.
CLIENT PROGRAM:
import java.io.*;
import java.rmi.*;
public class client
{
public static void main(String args[])throws Exception
{
try
{
String s="rmi://"+args[0]+"/abc";
serverint f=(serverint)Naming.lookup("rmi://localhost:5000/sonoo");
DataInputStream m=new DataInputStream(System.in);
int n1=Integer.parseInt(m.readLine());
System.out.println("The factorial is"+f.fact(n1));
}
catch(Exception e)
{
System.out.println(e);
}
}
}
INTERFACE PROGRAM:
import java.rmi.*;
public interface serverint extends Remote
{
int fact(int n)throws Exception;
}
IMPLEMENTATION PROGRAM:
import java.rmi.*;
import java.rmi.server.*;
public class serverimpl extends UnicastRemoteObject implements serverint
{
public serverimpl()throws Exception
{
super();
}
public int fact(int n)
{
inti,c=1;
for(i=1;i<=n;i++)
{
c=i*c;
}
return c;
}
}
SERVER PROGRAM:
import java.rmi.*;
import java.rmi.registry.*;
public class server
{
public static void main(String args[])
{
try
{
serverimpl m=new serverimpl();
Naming.rebind("rmi://localhost:5000/sonoo",m);
}
catch(Exception e)
{
System.out.println("Exception"+e);
}
}
}
OUTPUT:
SERVER WINDOW
c:mahi\32>javac serverint.java
c:mahi\mahi32>javac serverimpl.java
c:\mahi32>javac server.java
c:\mahi32>rmic serverimpl
c:\mahi32>start rmiregistry
c:\mahi32>java server
CLIENT WINDOW:C:\mahi32>javac client.java
C:\mahi32>java client localhost
3
The factorial is 6
16 . Write a program using RMI to access the database using the primary key
value and return the data to the client.
Server Interface:
import java.rmi.*;
import java.sql.*;
import java.util.*;
public interface serverint extends Remote
{
public String jdbc(int n)throws Exception;
}
Server Implementation:
import java.rmi.*;
import java.sql.*;
import java.util.*;
import java.rmi.server.*;
public class serverimpl extends UnicastRemoteObject implements serverint
{
public serverimpl()throws Exception{
}
public String jdbc(int n) throws Exception{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("jdbc:odbc:PVKR","PVKR","PVKR");
Statement stmt=con.createStatement();
ResultSetrs=stmt.executeQuery("SELECT * FROM emp where
empno="+n);
String s=" ";
while (rs.next()){
s=s+rs.getInt(1)+" ";
s=s+rs.getString(2)+" ";
s=s+rs.getString(3)+" ";
s=s+rs.getInt(4)+" ";
s=s+rs.getDate(5)+" ";
s=s+rs.getDouble(6)+" ";
s=s+rs.getDouble(7)+" ";
s=s+rs.getInt(8)+" ";
}
return s;
}
}
Server:
import java.net.*;
import java.rmi.*;
public class server
{
public static void main(String args[])
{
try
{
serverimpl m=new serverimpl();
Naming.rebind("abc1",m);
}
catch(Exception e)
{
System.out.println("Exception"+e);
}
}
}
Client:
import java.util.*;
import java.sql.*;
import java.io.*;
import java.rmi.*;
public class client
{
public static void main(String args[])throws Exception
{
try
{
String s="rmi://"+args[0]+"/abc1";
serverint f=(serverint)Naming.lookup(s);
DataInputStream m=new DataInputStream(System.in);
System.out.println("Enter empid from emp");
int n1=Integer.parseInt(m.readLine());
String rs=f.jdbc(n1);
System.out.println(rs);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
17. Write a html program for invoking servlet from applet.
MyServer.java:
import java.io.*;
import java.util.*;
import javax.servlet.*;
public class MyServer extends GenericServlet
{
public void service(ServletRequestreq,ServletResponse res)throws
ServletException,IOException
{
PrintWriter pw=res.getWriter();
Date d=new Date();
pw.println("<html><body bgcolor=blue><h2>Server Response</h2>");
pw.println("<h3>Current Date and Time From Server:</h3>");
pw.println("<b>"+d+"</b></body></html>");
}
}
web.xml:
<web-app>
<servlet>
<servlet-name>Applet</servlet-name>
<servlet-class>MyServer</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Applet</servlet-name>
<url-pattern>/MyServer</url-pattern>
</servlet-mapping>
</web-app>
AppletClient.java:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class AppletClient extends Applet implements ActionListener
{
public void init()
{
Label la=new Label("INVOKING SERVLET FROM APPLET");
la.setFont(new Font("Courier",Font.BOLD,15));
la.setForeground(Color.blue);
add(la);
Button b1=new Button("Click Here To Display Date Information From Server");
b1.setBackground(Color.black);
b1.setForeground(Color.white);
add(b1);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
try
{
AppletContext ac=getAppletContext();
URL url = new URL("http://localhost:8080/servlets3/MyServer");
ac.showDocument(url);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
AppletClient.HTML:
<html>
<head>
<title>Invoking Servlets From Applet</title>
</head>
<body bgcolor="violet">
<applet code="AppletClient.class" width="400" height="200">
</applet>
</body></html>
18. write a java servlet program to conduct online examination and to display
student mark list available in a database
StudentServlet3
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
int Total=0;
Connection connect;
Statement stmt=null;
ResultSetrs=null;
try
String url="jdbc:odbc:NEO";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
catch(ClassNotFoundExceptioncnfex)
cnfex.printStackTrace();
catch(SQLExceptionsqlex){sqlex.printStackTrace();}
catch(Exception excp){excp.printStackTrace();}
Seat_no=request.getParameter("Seat_no");
Name=request.getParameter("Name");
ans1=request.getParameter("group1");
ans2=request.getParameter("group2");
ans3=request.getParameter("group3");
ans4=request.getParameter("group4");
ans5=request.getParameter("group5");
if(ans1.equals("True"))Total+=2;
if(ans2.equals("False"))Total+=2;
if(ans3.equals("True"))Total+=2;
if(ans4.equals("False"))Total+=2;
if(ans5.equals("False"))Total+=2;
try{Statement stmt=connect.createStatement();
int result=stmt.executeUpdate(query);
stmt.close();}
catch(SQLException ex){}response.setContentType("text/html");
PrintWriter out=response.getWriter();out.println("<html>");
out.println("<head>");
out.println("</head>");
out.println("<body bgcolor=cyan>");
out.println("<center>");
out.println("<h1>"+message+"</h1>\n");
out.print("<br><br>");
out.println("<table border=5>");
try
Statement stmt=connect.createStatement();
rs=stmt.executeQuery(query);
out.println("<th>"+"Seat_no"+"</th>");
out.println("<th>"+"Name"+"</th>");
out.println("<th>"+"Marks"+"</th>");
while(rs.next()){out.println("<tr>");
out.print("<td>"+rs.getInt(1)+"</td>");
out.print("<td>"+rs.getString(2)+"</td>");
out.print("<td>"+rs.getString(3)+"</td>");
out.println("</tr>");}out.println("</table>");
catch(SQLException ex){ }
finally
try
if(rs!=null)rs.close();
if(stmt!=null)stmt.close();
if(connect!=null)connect.close();
catch(SQLException e)
{}
out.println("</center>");out.println("</body></html>");Total=0;}
Html Code:
<html>
<head>
<title>Database Test</title>
</head>
<body><center><h1>Online Examination</h1></center>
</form>
</body>
</html/>
Output:
19. Create a java program to create an airline reservation service and a travel
agent and the travel agent is searching for an airline using web services and
database.
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
var input;
varsecondInput;
var element;
varsecondElement;
varfirstCount = 0;
vareconomyCount = 0;
startArray()
{
input = window.prompt("Please type 1 for First Class and Please type 2 for
Economy.","0");
if (input == 1 || input == 2)
element = linearSearch(seats);
secondQuestion(seats);
secondQuestion(seats);
else
boarding Pass(input);
else
window.status="Byebye!";
System.exit(0);
}}}
function linear Search(the Array)
if (input == 1)
else if (input == 2)
return n;
return -1;
if (input ==1)
document.writeln("----------BOARDING PASS----------<br/>");
document.writeln("-----------------------------------------<br/>");
seats[element]= 1;
firstCount++;
document.writeln("----------BOARDING PASS----------<br/>");
document.writeln("-----------------------------------------<br/>");
seats[element]= 1;
economyCount++;
functionsecondQuestion(theArray)
if (input == 1)
if (theArray [n] == 0)
input = 2;
element=linear Search(seats);
boardingPass(input);
break;
else if (secondInput == 2)
else if (input == 2)
if (theArray [n] == 0)
if (theArray [n] == 0)
else if (secondInput == 2)
break;
</script>
</head>
</html>
20. Write a JSP program to calculate income tax, login and data capture.
Income Tax:
<html>
<head>
</head>
if (gender.equals("Male"))
prefix = "Mr.";
else if (gender.equals("Female"))
{
prefix = "Ms.";
float tax;
float diff;
tax = (float)0.1*diff;
}//end if
</body>
</html>
Datacapture.jsp
<html>
<head>
</head>
<body>
HashMaphm;
String uname;
String pwd;
Map.Entry entry;
hm = new HashMap();
uname = request.getParameter("username");
pwd = request.getParameter("password");
hm.put("Archie","Riverdale");
hm.put("Haddock", "Marlinspike");
hm.put("Hermione","Hogwarts");
Set s = hm.entrySet();
Iterator it = s.iterator();
while(it.hasNext())
if(uname.equals(entry.getKey()) &&pwd.equals(entry.getValue()))
login=true;
}//end while
if(login==true)
out.println("Welcome </FONT></B>");
out.println(uname);
out.println("Today is </FONT>"+dateFormat.format(date));
<form action="CalculateInterest.jsp" method = "post">
<br>
<br>
<br>
<option>IT Company</option>
<option>Private Bank</option>
<option>Insurance Company</option>
</select>
<br>
<br>
<br>
<br>
<input type = "submit" value = "Calculate Tax">
</form>
else
<jsp:forward page="Login.jsp">
</jsp:forward>
</body>
</html>
Login.jsp:
<html>
<head>
<title>Login Page</title>
</head>
<body>
<br>
Password:
<br>
</form>
</body>
</html>
Output: