Web Programming Lab Manual
Web Programming Lab Manual
in
INFORMATION TECHNOLOGY
[Type the abstract of the document here. The abstract is typically a short summary of the contents of the
document. Type the abstract of the document here. The abstract is typically a short summary of the
contents of the document.]
Program codings:
frames.html
<html>
<frameset cols = "50%,50%"> <frame src = "tablist.html"> <frame
src = "formup.html"> </frameset>
</html>
tablist.html:
<html>
<body>
</ul>
<table border ="3" cellpadding = "5" cellspacing = "7">
<tr>
<td rowspan = "3"><big><strong>Day</strong></big></td>
<td><strong> Morning</strong></td> <td><strong> Noon
</strong></td>
</tr>
<tr>
<td> 09:00 AM-01:00 PM </td> <td> 01:00 PM-05:00 PM </td>
</tr>
<tr>
</tr>
</table>
</body>
</html>
formup.html:
<html>
<head>
<title> Sign-In form </title> </head>
Cheque</td></tr>
</table>
<br>
<center>
</center>
</form>
</body>
</html>
Result:
Thus creating the webpage using HTML was executed successfully.
Algorithm:
1.Start the program.
Program codings:
pseudo.html:
<html>
<head>
<body>
<center>
<script type = "text/Javascript"> var a = "Information";
</center>
</body>
<title> Pseudo Classes for Hyperlinks </title> <style type =
"text/css"> a.col:link{color:blue} a.col:visited{color:black}
a.col:hover{color:orange}
a.big:link{color:skyblue}
a.big:visited{color:brown} a.big:hover{font-size:200%} </style>
</head>
<body>
<a class = "col" href = "form2.html" target = "_blank"> The text changes
Result:
Thus creating the webpage using DHTML was executed
successfully.
Aim:
To create a greeting using prompt and alert pop-up boxes
Algorithm:
1.Start the program
2.By using script language design a greeting for the user
3.Prompt is used to get the value
4.Alert is used to display or give any message to the user 5.Prompt and
alert are used in the javascript and create the pop-up
boxes for the greetings 6.Execute the program 7.get the output
Codings greet.html:
<html>
<head>
{
x1 =alert(?elcome+a+ ?o IT Department;
}
</script>
</head>
<body>
<script type =?ext/javascript var a =prompt(?nter username:;
call(a);
</script>
</body>
</html>
Result:
Thus the program is executed successfully and get the output
Aim:
To find the odd or even using scripting language
Algorithm:
1.Start the program
2.Using the javascript to find yhe odd/even 3.Using the for loop get
the n number
Codings even/odd.html
<html>
<head>
<style type =?ext/css body
{
background-color:black; color:#87CEFA; font-size:20; fontstyle:Times New Roman; text-align:center;
}
</style>
</head>
<body>
<script type =?ext/javascript
else
{
<body>
<html>
Result:
Thus the program is executed successfully and odd & even get in
alternative color.
Aim:
Algorithm:
Program:
<html>
<head>
<scrip type =?ext/javascript var a=[];
var sum=0;
{
var c=prompt(?nter the number; a.push();
sum+=parseInt(c);
}
alert(a+?um=sum);
</script>
</head>
</html>
Result:
The sumn of n numbers is calculated and displayed using javascript.
6. Form validation
Aim:
Algorithm:
Program:
<html>
<head>
<title> Student Registration form </title> <script>
function v()
{
if((document.f1.Name.value=="")||
(document.f1.Name.value==null))
{
alert("enter some name"); return false;
for(i=0;i<document.f1.Name.value.length;i++)
{
}
}
if((document.f1.age.value=="") || (document.f1.age.value==null))
}
for(i=0;i<document.f1.age.value.length;i++)
{
var ch1=document.f1.age.value.charAt(i); if(!ch1.match(/\d/))
}
}
if(document.f1.phone.value.length < 10 ||
document.f1.phone.value.length >10)
{
alert("Invalid phone number"); return false;
}
for(i=0;i<document.f1.phone.value.length;i++)
{
return false;
}
}
var emstr=document.f1.email.value; var indexat=emstr.indexOf("@"); var
len=emstr.length;
var indexdot=emstr.indexOf(".");
if((emstr==null) || (emstr.value==""))
{
alert("plaese enter email id"); return false;
}
if(indexat==-1 || indexdot==0 || indexat==indexdot)
{
alert("invalid Email ID"); return false;
}
if(emstr.indexOf("@",(indexdot+1))!=-1)
{
if(emstr.indexOf(" ")!=-1)
{
alert("invalid Email ID"); return false;
}
if(!document.f1.g1[0].checked && !document.f1.g1[1].checked)
{
alert("Please select Sex"); return false;
}
if(document.f1.g3.selectedIndex==0)
{
alert("Please SELECT any one COUNTRY"); return false;
}
return true;
}
</script>
</head>
<body>
<center><h3> Application Form</h3> </center> <form name="f1"
onsubmit=v()>
        <input
type="radio" name="g1" > Female<br/>
Reading<br/>
           
 <input type="checkbox" name="g2" value="TV">Watching
TV<br/>
<center>
</html>
Result:
Algorithm:
1.Start the program.
2.Create login page using HTML tags and validate the username
and password using the Javascript.
3.Create registration form to fill the details of the user.
4.Display the train details and user can reserve their seats
through online.
Program codings:
register.html
<html>
<head>
{
if((document.f1.Name.value=="")||(document.f1.Name.value==null))
{
alert("enter some name"); return false;
for(i=0;i<document.f1.Name.value.length;i++)
{
var ch=document.f1.Name.value.charAt(i);
if(!ch.match(/\w/))
alert("Invalid Name");
return false;
if((document.f1.age.value=="") || (document.f1.age.value==null))
{
alert("enter some age"); return false;
{
alert("Invalid age"); return false;
cseitquestions.blogspot.in | cseitquestions.blogspot.in |
cseitquestions.blogspot.in
for(i=0;i<document.f1.age.value.length;i++)
{
var ch1=document.f1.age.value.charAt(i);
if(!ch1.match(/\d/))
{
alert("Invalid Age");
return false;
if(document.f1.phone.value.length < 10 ||
document.f1.phone.value.length >10)
cseitquestions.blogspot.in | cseitquestions.blogspot.in |
cseitquestions.blogspot.in
{
alert("Invalid phone number");
return false;
}
for(i=0;i<document.f1.phone.value.length;i++)
var ch2=document.f1.phone.value.charAt(i);
if(!ch2.match(/\d/))
cseitquestions.blogspot.in | cseitquestions.blogspot.in |
cseitquestions.blogspot.in
return false;
}
var len=emstr.length;
var indexdot=emstr.indexOf(".");
if((emstr==null) || (emstr.value==""))
{
alert("plaese enter email id");
return false;
cseitquestions.blogspot.in | cseitquestions.blogspot.in |
cseitquestions.blogspot.in
}
if(indexat==-1 || indexdot==0 || indexat==indexdot)
{
alert("invalid Email ID");
return false;
}
if(emstr.indexOf("@",(indexdot+1))!=-1)
{
return false;
if(emstr.indexOf(" ")!=-1)
{
alert("invalid Email ID");
return false;
}
if(!document.f1.g1[0].checked && !document.f1.g1[1].checked)
{
alert("Please select Sex");
return false;
</script>
</head>
<body background="railways.gif"> <center>
<table>
<tr><td><a class=design><b>NAME :</b></td><td><input
type="text" name="userName" required></td></tr>
<br/><tr><td>
<br/>
<tr><td><a class=design><strong>
<tr><td><a class=design><b>NATIONALITY :
</b></td><td><select name="select">
</table>
<br/></br>
<center>
</html>
profile.html
<html>
<head>
<style>
h1{ font-size:300%; color:pink; font-family:century;
}
-------->>>><input type=button
onClick="location.href='home.html'" value="LOGOUT ">
<tr>
<td><b>TRAIN NUMBER</b></td> <td><b>FROM</b></td>
<td><b>TO</b></td> <td><b>DEPARTURE TIME</b></td>
<tr>
<td>2013</td>
<td>MADURAI</td>
<td>CHENNAI</td>
<td>6:00AM</td>
<td>800RS</td>
<td>10</td>
<tr>
<td>2015</td>
<td>MADURAI</td>
<td>GOA</td>
<td>7:00AM</td>
<td>1800RS</td>
<td>5</td>
<td> <input type="checkbox" name="book" value="book" > book
this train<input type="submit" value="Submit"></td>
</tr>
<tr>
<td>2813</td>
<td>CHENNAI</td>
<td>GOA</td>
<td>9:00PM</td>
<td>1800RS</td>
<td>3</td>
<td>11:30AM</td>
<td>300RS</td>
<td>20</td>
<td>GOA</td>
<td>CHENNAI</td>
<td>8:00AM</td>
<td>1800RS</td>
<td>10</td>
<td> <input type="checkbox" name="book" value="book" > book
this train<input type="submit" value="Submit"></td>
</tr>
<tr>
<td>2000</td>
<td>MADURAI</td>
<td>KOLKATTA</td>
<td>12:00PM</td>
<td>2800RS</td>
<td>100</td>
</tr>
</table>
</form>
</body>
</html>
note.html
<html>
<style>
font-size:120%;
}
note{
font -size=150%; font-famiy:cursive; color:red;
}
c{
color:green;
}
</style>
This web page is for booking the train tickets. this web site is a
mini project done by the students of IT-B(3rd year).
the users must first register on the web site to log in into their
account . the users must provide correct information
timings . the users can also book the train ticket and pay for the
ticket in online.
<tr>
</tr>
</body>
</html>
logo.html
<html>
<style>
login.html
<html><head>
<style>
a{
color:green; font-size:130%;
}
rani{
color:pink; font-size:150%;
}
</style>
</head>
<br>
<rani><marquee>IMPORTANT :The New Users click On register and
first register On the REGISTER FORM </marquee> </rani>
<br>
<center>
<table>
</table>
</form>
<form target="_blank">
<input type=button onClick="location.href='register.html'"
value="Register New user ">
</form>
</center>
</body>
</html>
home.html
<html>
<head>
<frameset rows="20%,80%"> <frame src="logo.html"> <frameset
cols="30%,70%"> <frame src="note.html"> <frame src="login.html">
</frameset>
</frameset>
</head>
</html>
Result:
Thus the Online railway reservation system website was
created succssfully.
Aim:
To display the student details according to rollno by linking xsl
document with xml document
Algorithm:
Program:
Student.xsl
<html>
<body>
</tr>
<!-- for-each processing instruction
students.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="students.xsl"?>
<class>
<marks>90</marks>
</student>
</class>
Result:
cseitquestions.blogspot.in | cseitquestions.blogspot.in |
cseitquestions.blogspot.in
9.Inheritance
Aim:
To perform single inheritance using Java.
Algorithm:
1.Start the program.
2.Perform single inheritance using extends keyword.
3.Execute the program.
Program Codings:
Inherit_Single.java
Inherit_Single() {
cseitquestions.blogspot.in | cseitquestions.blogspot.in |
cseitquestions.blogspot.in
SubClass() {
void display()
{
System.out.println(str);
}
class MainClass {
obj.display();
}
Result:
Thus the single inheritanve was executed successfully.
Aim:
To creating the simple application to access database using JDBC.
Algorithm:
1.Start the program.
JDBC driver would be loaded;
6.The ResultSet would be used to step through (or iterate through) the
rows returned and examine the data.
Program:
JDBCSample.java
import java.sql.*;
String connectionURL =
"jdbc:postgresql://localhost:5432/movies;user=java;password=samples"; //
Change the connection string according to your db, ip, username and
password
try {
If you are using any other database then load the right driver here.
while (rs.next())
System.out.println("Name= " + rs.getString("moviename") + "
Date= " + rs.getString("releasedate"));
}
catch (SQLException e) { e.printStackTrace();
}
finally {
}
}
Result:
Algorithm:
1.Importing java.sql package 2.Load and register JDBC driver.
3.Establishing a connection. 4.Creating a statement.
Program coding:
//import statements...
PASSWORD);
statement = connection.createStatement();
sqlEx.printStackTrace();
System.exit(1);
System.exit(1); } finally {
public static void createEmployee(int id, String name, int dept, int
sal, String loc){
preparedStatement = connection.prepareStatement("INSERT
INTO emp VALUES(?,?,?,?,?)");
System.exit(1); } finally {
try {
preparedStatement.close();
connection.close();
preparedStatement = connection.prepareStatement("UPDATE
emp SET salary=salary+? WHERE id=?");
System.exit(1); } finally {
Class.forName(JDBC_DRIVER);
connection = DriverManager.getConnection(DATABASE_URL,
USERNAME,PASSWORD);
preparedStatement = connection.prepareStatement("DELETE
FROM emp WHERE id=?");
preparedStatement.setInt(1, id)
System.exit(1); } finally {
try { Class.forName(JDBC_DRIVER);
connection = DriverManager.getConnection(DATABASE_URL,
USERNAME,
PASSWORD);
statement = connection.createStatement();
if (i != 3) System.out.printf("%-10s\t",
metaData.getColumnName(i).toUpperCase());
}
System.exit(1);
} finally { try {
statement.close();
connection.close();
try { Class.forName(JDBC_DRIVER);
connection = DriverManager.getConnection(DATABASE_URL,
USERNAME,
PASSWORD);
statement = connection.createStatement();
while (resultSet.next()) {
for (int i = 1; i <= noCols; i++) { if (i != 3)
System.out.printf("%-10s\t", resultSet.getObject(i));
}
System.out.println();
}
} catch (SQLException sqlEx) { sqlEx.printStackTrace();
System.exit(1);
System.exit(1);
} finally { try {
statement.close();
connection.close();
} catch (Exception e) { System.exit(1);
}
}
}
//createTable();
Result:
Thus the manipulating theDatabaseand SQLsexecutedsuccessfully
Program:
<?PHP
?>
}
else {
<?PHP
if ($db_found) {
}
else {
?>
Result:
13 . Install Tomcat and use JSP and link it with any of the
assignments above
Aim:
To Install Tomcat and use JSP and link it with any of the
assignments above
Algorithm:
1 . Install Java.
MONITOR TOMCAT
5 . Click on that icon and START TOMCAT, you can see the
following dialog box:
8 . It will show tomcat, as shown in above window. (if not, then try
again, may be a problem in installation or you?e not following
above steps correctly
9 . Now, go to: C:drive Programs Files
Apache Software Foundation tomcat
web-apps
10 . Open web-apps and ?opy your projector ?ake new folder which
Copy
Paste
11 . Create a text file and name it as first.jsp, use the code shown
below:
<html>
<head>
<title>blog post:ApacheTomcatServer</title>
</head>
<body>
<%-- START --%>
<%
out.println("UserName = amit2012, ");
out.println("Running first program in JSP.");
%>
<%-- END --%>
</body>
</html>
Program:
INDEX.JSP:
8">
<title>JSP Page</title> </head>
<body>
<form action="Result.jsp" method="GET">
<%
int i=0;
String q,ch1,ch2,ch3; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
on=DriverManager.getConnection("jdbc:odbc:exam1","",""); Statement
st=on.createStatement();
%>
<div id="ques" name="que"><%=q%></div>
</form>
</body>
</html>
RESULT.JSP
8">
<title>Result</title>
</head>
<body><%
int i=0,count=0;
on=DriverManager.getConnection("jdbc:odbc:exam1","",""); Statement
st=on.createStatement();
count++;
}
i++;
}
%><br><br><br><br>
<center>
Result:
Thus the installation of Tomcat and use JSP was
executed successfully.
Aim:
To read and write the files using .Net
Algorithm:
3Read and write the file using .Net 4Execute the file
Program:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="ReadWriteTextCSharp" %>
<!-- body {
margin-left: 0px; margin-top: 0px; margin-right: 0px; marginbottom: 0px;
}
a:link {
color: #0000FF;
}
a:visited {
color: #0000FF;
}
a:hover {
color: #0000FF; text-decoration: none;
}
a:active {
color: #0000FF;
}
.basix {
}
.lgHeader1 {
background-color: #CEE9FF;
}
--> </style>
</head>
<body>
<br />
<table align="center" border="0" cellpadding="0"
cellspacing="0" style="position: static"
width="752">
<tr>
C#.NET</td>
</tr>
<fieldset>
<legend>Save as</legend>Path:
<asp:TextBox ID="textboxPath" runat="server"
Width="237px"></asp:TextBox>File name: <asp:TextBox
ID="textboxName" runat="server" Width="93px"></asp:TextBox>
</table>
</form>
</tr>
</table>
</body>
</html>
Default.aspx.cs
using System.Web.UI.WebControls;
using System.IO;
{
textBoxContents.Text = File.ReadAllText(FilePath);
}
else
{
Response.Write("<script language='javascript'>window.alert('File
not found');</script>");
}
}
protected void buttonSave_Click(object sender, EventArgs e)
{
DirectoryInfo Folder = new DirectoryInfo(textboxPath.Text); if
(Folder.Exists)
{
if (textboxName.Text != string.Empty)
{
string FilePathSave = Folder.ToString() + textboxName.Text;
File.WriteAllText(FilePathSave, textBoxContents.Text);
}
else
{
}
}
else
{
Response.Write("<script language='javascript'>window.alert('Folder not
found');</script>");
}
}}
Result:
Thus the reading and writing the files using .net executed
successfully
Aim:
To Write a program to implement web service for calculator
application
Algorithm:
1Create new project
Program:
using System;
using System.Collections.Generic; using System.Linq;
using System.Web;
using System.Web.Services;
namespace calc
{
[WebService(Namespace = "mycalculatorexample.org")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
{
[WebMethod]
public string calculate(string first, string second, char sign)
{
{
case '+':
{
result = (Convert.ToInt32(first) +
Convert.ToInt32(second)).ToString(); break;
}
case '-':
{
result = (Convert.ToInt32(first) Convert.ToInt32(second)).ToString(); break;
}
case '*':
{
result = (Convert.ToInt32(first) *
Convert.ToInt32(second)).ToString(); break;
}
case '/':
{
result = (Convert.ToInt32(first) /
Convert.ToInt32(second)).ToString(); break;
}
case '%':
{
result = (Convert.ToInt32(first) %
Convert.ToInt32(second)).ToString(); break;
}
default:
result = "Invalid"; break;
}
return result;
}
}
}
Result: