Web Tech Lab Manual Net
Web Tech Lab Manual Net
2012 - 2013
10144IT607 WEB TECHNOLOGY LABORATORY
VI SEMESTER
B.Tech
PREPARED BY
APPROVED BY
Mr.M.Venkatesh
Dr.A.Askarunisa
(HOD / CSE)
10144IT607
0 0 3 2
TOTAL=45 PERIODS
(KOVAI.HTML)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<head>
<title>kovai district map</title>
</head>
<body text="black">
<img src="coimbatore.jpg">
<p>
<font size="3.9">
Coimbatore, also known as Kovai,it is the second largest city in the Indian state of </p>
<p>Tamil Nadu and the 15th largest urban agglomeration in India with a metropolitan population
of</p><p> over 2 million.It is the second largest urban agglomeration in the
state.</p></font></p>
</body>
</html>
(MADURAI.HTML)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<head>
<title>Madurai</title>
</head>
<body text="black">
<img src="madurai_map.jpg" align="middle">
<font size="4">
<p>Madurai is the administrative headquarters of Madurai<p> District
in the South Indian state of Tamil Nadu.</p> It is the third largest city
in Tamilnadu next to Chennai and Coimbatore and the <p>second largest
municipal corporation in Tamil Nadu next only to Chennai.It is the
most important city in Tamil Nadu state after Chennai and Coimbatore
respectively.</p> It is the capital of Tamil Nadu by administration
headquarters of southern districts in Tamil Nadu.<p>Located on the
banks of River Vaigai, it has been a major settlement for over two millennia.
</p>
</font>
</body>
</html>
(TRICHY.HTML)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<head>
<title>Trichy</title>
</head>
<body text="black">
<img src="trichy mpa.jpg">
<font size="4">
<p>Tiruchirappalli also called Tiruchi or Trichy, is a city in the</p> <p> Indian state of Tamil
Nadu and the administrative headquarters of Tiruchirappalli District.</p> <p> It is the Fourth
largest municipal corporation in Tamil Nadu and also the Fourth largest urban agglomeration in
the state.
</p>
</font>
</body>
</html>
OUTPUT:
TRICHY.HTML
RESULT:
Thus web page with embed an image map and with hot spots and related information
are successfully created.
AIM:
To create a web page by using external as well as internal style sheets.
ALGORITHM :
Step 1: Create a HTML page with necessary DOC TYPE.
Step 2: Give the title in the head tag.
Step 3: Create a internal style sheet in the head using style tag,
Step 4: Call the external style sheet file XYZ.CSS using link real attribute.
Step 5: In the body tag ,using the style sheet class give the contents.
Step 6: In h3 tag create a table using external style sheet.
Step 7: Display the output.
Step 8: Close.
PROGRAM CODING:
(XYZ.CSS)
h3{font_family:arial;font_size:20;color:cyan}
table{border_color:green}
td{font_size;20pt;color:magenta}
(EXP2.HTML)
<html>
<head><h1><center> ALL STYLE SHEETS</center></h1>
<title>USE OF INTERNAL AND EXTERNAL STYLE SHEETS
</title>
<link rel="style sheet" href="xyz.css"type="text/css">
<style type="text/css">
.vid{font_family:verdana;font_style:italic,color:red;text_align:center}
.ani{font_family:tahoma;font_style:italic;font_size:20;text_align:center;}
font{font_family:georgia;color:blue;font_size:20}
ul{list_style_type:circle}
</style>
</head>
<body>
</ol>
<p style="font_size;20pt;color:purple"> Vickram College of Engineering </p>
<p class="ani"> Vickram college of engineering is owned by M.K.S.Srinivasan <br> It is
approved by AICTE. Affilaiated to anna university chennai <br></p>
<h2 class="vid"> Vickram College of Engineering </h2>
<br>
<font> It is an ISO certified institution </font><br>
<br>
<font>
<h2> List of subjects</h2>
<ul>
<li> Numerical method </li>
<li> Web Technology </li>
<li> Network proramming management </li>
<li> Cryptography and network security </li>
<li> Embedded System </li>
<li> Object Oriented Analysis And Design </li>
</ul>
</font>
<h3> Internal mark list </h3>
<table width="100%"cellspacing="2"cellpadding="2"border="5">
<tr>
<th> S.Name </th>
<th> Marks </th>
OUTPUT:
RESULT:
Thus we created a web page by using as well as internal style sheets and successfully
executed.
3.Client Side Scripts for validating Web Forms Controls using DHTML.
AIM:
Create a client side script for validatinig web form controls usiing HTML.
ALGORITHM:
Step 1: Create a html page using script tag.
Step 2: Define the function validate and define all the validation opearation.
Step 3: Produce the alert message on incomplete submission and also for complete
Submission.
Step 4: In the body attribute tag define background font colors and font style.
Step 5: Create the input type label as a name,depart and id number.
Step 6: Fix the range of the id number as input using max length.
Step 7: On clciking the submit button the validating form function will invoke.
Step 8: Execute the html code in internet explorer on any of the browser.
PROGRAM CODING:
<html>
<head>
<title>validation checking </title>
</head>
<script language="javascript"> function passwordStrength(password)
{
var str1="strong"; var str2="weak";
if (password.length > 6)
document.getElementById("passwordDescription").innerHTML =str1; else
document.getElementById("passwordDescription").innerHTML =str2;
}
function a()
{
var i=document.form1.uname.value; var a=i.length;
var j=document.form1.pass.value; var b=j.length;
if(a==0&&b==0)
window.alert("Enter username and password"); else
{
if(a==0)
window.alert("Enter username "); if(b==0)
window.alert("Enter password");
}
if(a!=0&&b!==0&&b<7) window.alert("password is too short");
}
</script> <body>
<form name="form1" >
<font color="red"><marquee>WEBSITE MODERATORS : </marquee></font>
<br> <br>
UserName:<input type="text" name="uname">@india.com <br>
OUTPUT:
RESULT:
Thus we created a client side script for validating web form controls using DHTML.
AIM:
To write programs in java to create applets incorporating the following features.
i) Create a color palette with matrix of buttons.
ii) Set background and foreground of the control text area by selecting a color from color
palette.
iii) In order to select foreground and background use checkbox control as radio button.
iv) To set background images.
ALGORITHM:
Step 1: Include all necessary header files.
Step 2: Initialize the applet code with height as 800 and width as 300.
Step 3: Extend applet/code with height as 800 and width as 300 which implements
ItemListener
Step 4: Initialize the six buttons with red , blue , green , yellow , magenta and white.
Step 5: The default color of background is white.
Step 6: The default color of text is set as black.
Step 7: Image can be imported.
Step 8: Run the program.
PROGRAM CODING:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code="exp" width=400 height=400>
</applet>*/
public class exp extends Applet implements ItemListener
{
int currcolor=5;
int flag=1;
add(box3);
box1.addItemListener(this);
box2.addItemListener(this);
box3.addItemListener(this);
}
public void itemStateChanged(ItemEvent ev)
{
if(box1.getState()==true)
flag=1;
else if(box2.getState()==true)
{
text="Default color is black";
flag=2;
}
else if(box3.getState()==true)
{
img=getImage(getDocumentBase(),"Blue hills.jpg");
flag=3;
}
repaint();
}
public void paint(Graphics g)
{
if(flag==2)
{
g.drawString(text,30,100);
switch(currcolor)
{
case 0:
g.setColor(Color.red);
break;
case 1:
g.setColor(Color.blue);
break;
case 2:
g.setColor(Color.green);
break;
case 3:
g.setColor(Color.yellow);
break;
case 4:
g.setColor(Color.magenta);
break;
case 5:
g.setColor(Color.black);
break;
}
g.drawString(text,30,100);
}
else if(flag==1)
{
g.drawString(text,30,100);
switch(currcolor)
{
case 0:
setBackground(Color.red);
break;
case 1:
setBackground(Color.blue);
break;
case 2:
setBackground(Color.green);
break;
case 3:
setBackground(Color.yellow);
break;
case 4:
setBackground(Color.magenta);
break;
case 5:
setBackground(Color.white);
break;
}
}
else if(flag==3)
{
g.drawImage(img,20,90,this);
}
}
public boolean action(Event e,Object o)
{
for(int i=0;i<5;i++)
{
if(e.target==buttons[i])
{
currcolor=i;
text="You have chosen "+colours[i];
repaint();
return true;
}
}
return false;
}
}
OUTPUT:
RESULT:
Thus the java program for color palette, with background, foreground and to set
background images is creates and executed successfully.
pw.close();
}
}
Web.xml
servlet>
<servlet-name>server</servlet-name>
<servlet-class>server</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>server</servlet-name>
<url-pattern>/servlet/server</url-pattern>
</servlet-mapping>
Output:
Result:
Thus the program for invoking servlets from html file was successfully executed..
PROGRAM CODING:
Applet.html
<html>
<head>
<title>Invoking Servlets From Applet</title>
</head>
<body bgcolor="violet">
<applet code="AppletClient.class" width="400" height="200">
</applet>
</body>
</html>
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/servlet/MyServer");
ac.showDocument(url);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
MyServer.java
import java.io.*;
import java.util.*;
import javax.servlet.*;
public class MyServer extends GenericServlet
{
public void service(ServletRequest req,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
<servlet>
<servlet-name>AppletClient</servlet-name>
<servlet-class>MyServer</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AppletClient</servlet-name>
<url-pattern>/servlet/MyServer</url-pattern>
</servlet-mapping>
OUTPUT:
RESULT:
Thus the program for invoking servlets from applet was successfully executed..
For displaying the student mark list. Assume student information is available in a
database which
has been stored in a database server.
ALGORITHM:
STEP 1: Start the program.
STEP 2: Write a servlet program using JSP
STEP 3: Create a Database in MS-ACCESS and name it as studentDB1.mdb
STEP 4: Save the JSP program with extension of jsp.
STEP 5: Open the saved file using web browser.
STEP 6: Stop the program.
PROGRAM:
HomePage.html
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:StudentDB1";
connect = DriverManager.getConnection(url, " ", " ");
if(request.getParameter("action")!=null)
{
SeatNum = request.getParameter("Seat_no");
Name = request.getParameter("Name");
ans1 =request.getParameter("group1");
if(ans1.equals("True"))
a1=2;
else
a1=0;
ans2 = request.getParameter("group2");
if(ans2.equals("True"))
a2=0;
else
a2=2;
ans3 = request.getParameter("group3");
if(ans3.equals("True"))
a3=0;
else
a3=2;
ans4 = request.getParameter("group4");
if(ans4.equals("True"))
a4=2;
else
a4=0;
ans5 = request.getParameter("group5");
if(ans5.equals("True"))
a5=0;
else
a5=2;
int Total=a1+a2+a3+a4+a5;
stmt = connect.createStatement();
String query = "INSERT INTO StudentTable (" + "Seat_no,Name,Marks" + ")
VALUES ('" +SeatNum + "', '" + Name + "', '"+Total+ "')";
int result = stmt.executeUpdate(query);
stmt.close();
stmt = connect.createStatement();
query = "SELECT * FROM StudentTable WHERE Name="+"'"+Name+"'";
rs = stmt.executeQuery(query);
%>
<html><head><title>Student Mark List</title></head>
<body bgcolor=khaki>
<center>
<h2>Students Marksheet</h2>
<h3>Name of the College:ABC College of Engineering</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(rs.next())
{
%>
<tr>
<td><%=rs.getInt(1)%></td>
<td> <%=rs.getString(2)%></td>
<td> <%=rs.getString(3)%></td>
</tr>
<%
}
rs.close();
stmt.close();
connect.close();
%>
</table>
</center>
<br/> <br/><br/>
<table>
<tr><td><b>Date:<%=new java.util.Date().toString() %></td></tr>
<tr><td><b>Signature: X.Y.Z. <b></td></tr>
</table>
<div>
<a href="http://127.0.0.1:8080/jsp-examples/StudExam/Exam.jsp">Click here to go
back</a>
</body>
</html>
<%}else{%>
<html>
<head><title>Online Examination</title>
<script language="javascript">
function validation(Form_obj)
{
if(Form_obj.Seat_no.value.length==0)
{
alert("Please,fill up the Seat Number");
Form_obj.Seat_no.focus();
return false;
}
if(Form_obj.Name.value.length==0)
{
alert("Please,fill up the Name");
Form_obj.Name.focus();
return false;
}
return true;
}
</script>
</head>
<body bgcolor=lightgreen>
<center>
<h1>OnLine Examination</h1>
</center>
<form action="Exam.jsp" 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/>
<center>
<input type = "submit" value="Submit">
<input type = "reset" value="Clear"><br><br>
</center>
</form>
<%}%>
OUTPUT:
RESULT:
Thus the Web page using JSP has been executed successfully.
To write a XSL program for converting the given XML document into equivalent
XHTML.
ALGORITHM:
STEP 1: Start the program.
STEP 2: Write a sample XML program.
STEP 3: write a XSL program that contains the XSL elements for converting into
XHTML file
STEP 4: Insert the following tag in the second line of the XML file
<?xml-stylesheet type="text/xsl" href="7thexp.xsl"?>
STEP 5: Open the saved XML file using web browser.
STEP 6: Stop the program.
PROGRAM
7thexp.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy -->
<?xml-stylesheet type="text/xsl" href="7thexp.xsl"?>
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>two of our famous Belgian Waffles with plenty of real maple syrup</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>light Belgian waffles covered with strawberries and whipped cream</description>
<calories>900</calories> </food>
<food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>light Belgian waffles covered with an assortment of fresh berries and whipped
cream</description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<description>thick slices made from our homemade sourdough bread</description>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description>
<calories>950</calories>
</food>
</breakfast_menu>
7thexp.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy -->
<html
xsl:version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
<xsl:for-each select="breakfast_menu/food">
<div style="background-color:teal;color:white;padding:4px">
<span style="font-weight:bold"><xsl:value-of select="name"/></span>
<xsl:value-of select="price"/>
</div>
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<xsl:value-of select="description"/>
<span style="font-style:italic">
<xsl:value-of select="calories"/> (calories per serving)
</span>
</div>
</xsl:for-each>
</body>
</html>
OUTPUT
RESULT:
Thus the program for converting the XML into XHTML file using the XSLT
executed successfully.
OUTPUT
OUTPUT
RESULT
Thus the XML program is parsed and executed using DOM parser and SAX parser
separately.
//source file
<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();
}
</script>
</head>
<body>
<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<button type="button" onclick="loadXMLDoc()">Change Content</button>
</body>
</html>
OUTPUT:
//output1
Let AJAX change this text
//output2
AJAX is not a new programming language.
AJAX is a technique for creating fast and dynamic web pages.
RESULT:
Thus the program using AJAX is executed successully.
10. Consider a case where we have two web Services an airline service and a travel
agent and the travel agent is searching for an airline. Implement this scenario using
Web Services and Data base.
AIM:
To create an airline reservation service and a travel agent and the travel agent is
searching for an airline using webservices and database
ALGORITHM:
Step 1: Start the Program
Step 2: Create a root process for Reservation
Step 3: Create a service with focus on each item
Step 4: Output the items
Step 5: Stop
Program:
<?xml version = "1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Airline Reservation System-->
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>Airline Reservation System</title>
<script type = "text/javascript">
<!-- var input;
var secondInput;
var element;
var secondElement;
var firstCount = 0;
var economyCount = 0;
var seats = [ ,0,0,0,0,0,0,0,0,0,0]; //allocate 10-element Array
function startArray()
{
for(var i=0; i<11; i++)
{
input = window.prompt("Please type 1 for First Class and Please type 2 for
Economy.","0");
if (input == 1 || input == 2)
{
element = linearSearch(seats);
if (element==-1 && input == 1)
{
document.writeln("The First Class is already fully booked<br/>");
secondQuestion(seats);
}
else if (element ==-1 && input == 2)
{
document.writeln("The Economy Class is already fully booked<br/>");
secondQuestion(seats);
}
else
boardingPass(input);
} //to terminate the program
else
{
window.status = "Bye-bye!";
System.exit(0);
}}}
function linearSearch(theArray)
{
if (input == 1)
{
for (var n=0; n<6 ; n++)
if (theArray [n] == 0)
return n;
}
else if (input == 2)
{
{
secondInput = window.prompt("Do you want to move to Economy Class? (If YES,
please press 1. If NO, please press 2)","0");
if ( secondInput == 1)
{
input = 2;
element=linearSearch(seats);
document.writeln("You have been allocated to Economy Class<br/>");
boardingPass(input);
break;
}
else if (secondInput == 2)
{ document.writeln("Next flight leaves in 3 hours<br/>");
break;
} }}
}
else if (input == 2)
{
for (var n=0; n<6 ;n++)
{
if (theArray [n] == 0)
{
secondInput = window.prompt("Do you want to move to First Class? (If YES, please
press 1. If NO, please press 2)","0");
if ( secondInput == 1)
{
input = 1;
element=linearSearch(seats);
document.writeln("You have been allocated to First Class<br/>");
boardingPass(input);
break;
}
else if (secondInput == 2)
{
Result:
The web service for the required application is created.