WEB PROGRAMMING LAB MANUAL
Comments
Content
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
INFORMATION TECHNOLOGY
IT6512 Web Programming
Laboratory
Lab manual
Anna university,Chennai.
Regulation 2013
[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.]
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
1.Creating webpage using HTML
Aim:
To create webpage that contains form,frame,table,list,link using
HTML
Algorithm:
1.Start the program.
2.Use the specific HTML tags to display the webpage that
contains frame,form,table,list,link.
3.Execute the program. 4.Stop the program.
Program codings:
frames.html
<html>
<frameset cols = "50%,50%"> <frame src = "tablist.html"> <frame
src = "formup.html"> </frameset>
</html>
tablist.html:
<html>
<body>
<p align = "center"><font face = "Times new roman" size = "5"
color = "Red">List of Departments</p>
<ul type ="square">
<li>Information Technology</li> <li>Mechanical Engineering</li>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<li>Electronics and Communication Engineering</li> <li>Computer
Science Engineering</li>
</ul>
<table border ="3" cellpadding = "5" cellspacing = "7">
<caption align = "Top"><b><font size = "6"/><i>Schedule</i></b>
</caption>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<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>
<td> 10:00 AM-01:00 PM </td> <td> 02:00 PM-05:00 PM </td>
</tr>
</table>
</body>
</html>
formup.html:
<html>
<head>
<title> Sign-In form </title> </head>
<body bgcolor = "pink"> <center>
<form name = "form1"> <table>Program codings:
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<tr><td><b> Name:</b></td><td><input type = "text" name =
"name"></tr>
<tr><td><b> Password:</b></td><td><input type = "password"
name = "pwd"></tr>
<tr>
<td><b> Gender: </b></td><td><input type = "radio" name =
"group1" value = "male"> Male </td>
<td><b> Gender: </b></td><td><input type = "radio" name =
"group1" value = "female"> Female </td>
</tr>
<tr><td><b> Hobby </b></td></tr>
<td> <input type = "checkbox" name="option1" value="atm"> ATM
card </td></tr>
<tr><td><input type = "checkbox" name="option1" value="cheque">
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
Cheque</td></tr>
</table>
<br>
<center>
<input type = "submit" value= "Submit"> <input type = "reset" value =
"Reset">
</center>
</form>
</body>
</html>
Result:
Thus creating the webpage using HTML was executed successfully.
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
2.Creating webpage using DHTML
Aim:
To create webpage using DHTML.
Algorithm:
1.Start the program.
2.Use javascript and Css concept to develop the webpage.
3.Execute the program.
4.Stop the program.
Program codings:
pseudo.html:
<html>
<head>
<body>
<center>
<script type = "text/Javascript"> var a = "Information";
document.write("<h2>" + a + "Technology" + "</h2>"); </script>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
</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>
<h3> Move the mouse over the text </h3> <p>
<em>
<a class = "col" href = "form2.html" target = "_blank"> The text changes
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
the color </a> </em>
</p>
<p>
<em>
<a class = "big" href = "form2.html" target = "_blank"> The
text is getting big in size </a>
</em>
</p>
</body>
</html>
Result:
Thus creating the webpage using DHTML was executed
successfully.
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
3.Creating a greetings using pop-up BOXES
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>
<script type=?ext/javascript function call(x1)
{
x1 =alert(?elcome+a+ ?o IT Department;
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
}
</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
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
4.Display even & odd numbers using javascript
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
4.Prompt is used to get the n value then the function is called
5.Alternatively printing the odd number is one color and even
number is some other color
6.Execute the program and output page is displayed
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;
}
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
</style>
</head>
<body>
<script type =?ext/javascript
document.write(h2>Display Odd and Even Numbers</h2>;
var range = prompt(?nter the range;
if(range==null)
{
alertt(?o count will be shown as you clicked Cancel;
}
else if(range==?)
{
alert(?ange must be entered;
}
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
else
{
document.write(?dd Numbers are:; document.write(br>;
for(i=0;i<=range;i++)
{
if(i%2==1)
document.write(i+br>;
}
document.write(?ven Numbers are:; document.write(br>;
for(i=0;i<=range;i++)
{
if(i%2==0)
document.write(i+br>;
}
}
document.write(br><br>;
</script>
<body>
<html>
Result:
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
Thus the program is executed successfully and odd & even get in
alternative color.
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
5. Displaying sum of n numbers using javascript
Aim:
To calculate and display the sum of n numbers using javascript
Algorithm:
1.Start the program 2.declare the sum=0
3.enter the number of elements using prompt and assign it in 'n'
4.apply for loop to print the elements
5.perform push function to get sum value 6.print the summation
value using alert box 7.stop the program
Program:
<html>
<head>
<scrip type =?ext/javascript var a=[];
var sum=0;
var n=prompt(?nter number of elements; for(i=0;i<n;i++)
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
{
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.
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
6. Form validation
Aim:
to perform the form validation using javascript.
Algorithm:
1.start the program
2.assign condition to get name field 3.assign condition for age
4.assign condition for phone number
3.asign condition to get email field and a radio button
4.have a checkbox for hobby and give a select down arrow for
selecting country
4.validate the form 5.execute the program 6.stop the program
Program:
<html>
<head>
<title> Student Registration form </title> <script>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
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++)
{
var ch=document.f1.Name.value.charAt(i); if(!ch.match(/\w/))
{
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
alert("Invalid Name"); return false;
}
}
if((document.f1.age.value=="") || (document.f1.age.value==null))
{
alert("enter some age"); return false;
}
if((document.f1.age.value <10)|| (document.f1.age.value > 22))
{
alert("Invalid age"); return false;
}
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;
}
}
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
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++)
{
var ch2=document.f1.phone.value.charAt(i); if(!ch2.match(/\d/))
{
alert("Invalid phone number");
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
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)
{
alert("invalid Email ID"); return false;
}
if(emstr.indexOf(" ")!=-1)
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
{
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.g2[0].checked && !document.f1.g2[1].checked &&
!document.f1.g2[1].checked)
{
alert("Please tick any one hobbie"); return false;
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
}
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()>
<strong> Name:</strong><input type="text" name="Name"><br/>
<strong> Age:</strong><input type="text" name="age"><br/>
<strong> Phone:</strong><input type="text" name="phone"><br/>
<strong> EmailID:</strong><input type="text" name="email"><br/>
<strong> Sex:</strong> <input type="radio" name="g1">
Male<br/>
        <input
type="radio" name="g1" > Female<br/>
<strong> Hoby:</strong>  <input type="checkbox" name="g2"
value="Singing">Singing<br/>
           
 <input type="checkbox" name="g2" value="Reading">
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
Reading<br/>
           
 <input type="checkbox" name="g2" value="TV">Watching
TV<br/>
<strong> Country:</strong><select name="g3"> <option
value="I">India</option>
<option value="C">China</option> <option
value="S">Srilanka</option> </select>
<center>
<input type="submit" name="submit" value="submit"> <input
type="reset" name="reset" value="Reset"> <br/> </center>
</form>
</body>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
</html>
Result:
Thus the form validation using javascript was executed
succesfully.
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
7.Creating the website
Aim:
To create the Online railway reservation system website using
HTML,Javascript and Css.
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.
5.Stop the program.
Program codings:
register.html
<html>
<head>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<title> ONLINE TRAIN TICKET BOOKING ( REGISTER )</title>
<style>
h1{
font-family:monotype corsiva; color:white;
font-size:300%;
}
a.design{ font-family:cursive; color:green;
}
</style>
<script> function v()
{
if((document.f1.Name.value=="")||(document.f1.Name.value==null))
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
{
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;
}
}
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
if((document.f1.age.value=="") || (document.f1.age.value==null))
{
alert("enter some age"); return false;
}
if((document.f1.age.value <10)|| (document.f1.age.value > 22))
{
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/))
{
alert("Invalid phone number");
cseitquestions.blogspot.in | cseitquestions.blogspot.in |
cseitquestions.blogspot.in
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;
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)
{
alert("invalid Email ID");
return false;
}
if(emstr.indexOf(" ")!=-1)
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
{
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>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<h1> REGISTRATION </h1>
<for7.Creating the websitem name="f1" onsubmit=v()>
<table>
<tr><td><a class=design><b>NAME :</b></td><td><input
type="text" name="userName" required></td></tr>
<br/><tr><td>
<a class=design><strong> AGE:</strong></td><td><input
type="text" name="age"></td><tr>
<br/>
<tr><td><a class=design><strong> PHONE
NUMBER:</strong></td><td><input type="text"
name="phone"></td><tr>
<br/>
<tr><td><a class=design><strong> EMAILID:</strong></td><td><input
type="text" name="email"></td><tr>
<br/>
<tr><td><a class=design><strong>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
SEX:</strong> </td><td><input type="radio" name="g1">
Male<input type="radio" name="g1" >
Female<br/> <strong> </td><tr>
<tr><td><a class=design><b>PASSWORD :</b></td><td><input
type="password"name="pwd" required></td></tr>
<tr><td><a class=design><b>RE-ENTER PASSWORD
:</b></td><td><input type="password" name="rpwd"
required></td></tr>
<tr><td><a class=design><b>NATIONALITY :
</b></td><td><select name="select">
<option value="INDIAN">INDIAN</option> <option
value="OTHER">OTHERS</option> </select></td></tr>
</table>
<br/></br>
<center>
<input type=button onClick="location.href='login.html'"
value="Click Here To Complete Registration">
</html>
profile.html
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<html>
<head>
<style>
h1{ font-size:300%; color:pink; font-family:century;
}
h2{ font-size:20px; color:red;
}
</style>
</head>
<body background="bg5.jpg"> <h1>PROFILE</h1><center> <form
target="_blank">
-------->>>><input type=button
onClick="location.href='home.html'" value="LOGOUT ">
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<<<<---------- </form></center> <br>
<center>
<img src="pro.jpeg" align="center" alt="rail" width="230"
height="150">
<h2>Name : Rajkamal <br> ID : 2013-135106-2017<br>
<h2></center>
<center><b> TRAIN DETAIL LIST : </b></centr> <table border="1"
style="width:100%">
<tr>
<td><b>TRAIN NUMBER</b></td> <td><b>FROM</b></td>
<td><b>TO</b></td> <td><b>DEPARTURE TIME</b></td>
7.Creating the website<td><b>TRAIN FAIR</b></td>
<td><b>SEATS AVALIBLE</b></td>
<td><b>BOOK TICKET</b> </td> </tr>
<tr>
<td>2013</td>
<td>MADURAI</td>
<td>CHENNAI</td>
<td>6:00AM</td>
<td>800RS</td>
<td>10</td>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<td> <input type="checkbox" name="book" value="book" > book
this train<input type="submit" value="Submit"></td>
</tr>
<tr>
<td>2014</td>
<td>MADURAI</td>
<td>DELHI</td>
<td>3:00AM</td>
<td>2200RS</td>
<td>4</td>
<td> <input type="checkbox" name="book" value="book" > book
this train<input type="submit" value="Submit"></td>
</tr>
<tr>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<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> <input type="checkbox" name="book" value="book" > book
this train<input type="submit" value="Submit"></td>
</tr>
<tr>
<td>2334</td>
<td>TIRCHY</td>
<td>KANYAKUMARI</td>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<td>11:30AM</td>
<td>300RS</td>
<td>20</td>
<td> <input type="checkbox" name="book" value="book" > book
this train<input type="submit" value="Submit"></td>
</tr>
<tr>
<td>2295</td>
<td>MADURAI</td>
<td>PUNJAB</td>
<td>6:00PM</td>
<td>2800RS</td>
<td>30</td>
<td> <input type="checkbox" name="book" value="book" > book
this train<input type="submit" value="Submit"></td>
</tr>
<tr>
<td>2030</td>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<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>
<td> <input type="checkbox" name="book" value="book" > book
this train<input type="submit" value="Submit"></td>
</tr>
<tr>
<td>2995</td>
<td>MADURAI</td> <td>JAMMU & KASHMIR</td>
<td>7:00PM</td> <td>2000RS</td>
<td>104</td>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<td> <input type="checkbox" name="book" value="book" > book
this train<input type="submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
note.html
<html>
<style>
body{ font-famiy:serif; color:white;
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
font-size:120%;
}
note{
font -size=150%; font-famiy:cursive; color:red;
}
c{
color:green;
}
</style>
<body background="bg.jpg"> <note><b>NOTE : </b></note>
<blink><c>IMPORTANT </c></blink> <br>
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
while typing in the registration form so that there wont be any
problems . the users can watch the list of trains and their
timings . the users can also book the train ticket and pay for the
ticket in online.
<tr>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<td valign="top"><p align="center" color="red"><br><hr><marquee
direction="down"><img src="i1.jpeg"/><br><br><img
src="i2.jpeg"/><br><br><img src="i3.jpeg"/><br><br><img
src="i4.jpeg"/><br><br><img src="i1.jpeg"/><br><br><img
src="i2.jpeg"/><br><br><img src="i3.jpeg"/><br><br><img
src="i4.jpeg"/><img src="i1.jpeg"/><br><br><img
src="i2.jpeg"/><br><br><img src="i3.jpeg"/><br><br><img
src="i4.jpeg"/><img src="i1.jpeg"/><br><br><img
src="i2.jpeg"/><br><br><img src="i3.jpeg"/><br><br><img
src="i4.jpeg"/></marquee></td>
</tr>
</body>
</html>
logo.html
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<html>
<style>
h1{ font-size:200%; color:red; font-family:arial;
}
</style>
<body background="bg1.jpg">
<img src="logo3.gif" align="right" alt="rail" width="130"
height="100"> <img src="logo2.gif" align="left" alt="rail" width="130"
height="100"> <h1><center>ONLINE TRAIN TICKET
BOOKING</center></h1> </html>
login.html
<html><head>
<style>
a{
color:green; font-size:130%;
}
rani{
color:pink; font-size:150%;
}
</style>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
</head>
<body background="bg.jpg"> <br>
<br>
<rani><marquee>IMPORTANT :The New Users click On register and
first register On the REGISTER FORM </marquee> </rani>
<br>
<center>
<table>
<tr><td><a><b>NAME :</b></td><td><input type="text"
name="userName"></td></tr> <tr><td><a><b>PASSWORD
:</b></td><td><input type="password"name="pwd"></td></tr>
</table>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<form action="profile.html" method="get" target="_blank"> <input
type="submit" value="LOGIN"/>
</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>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
Result:
Thus the Online railway reservation system website was
created succssfully.
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
8.Linking of xsl document with xml
Aim:
To display the student details according to rollno by linking xsl
document with xml document
Algorithm:
1.start the program
2.create the xml document with student detail
3.create an xsl document and template to find the root directory
4.use for each to select all the student details and display it
5.display the details of student according the rollno by sort
6.stop the program
Program:
Student.xsl
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet
version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<html>
<body>
<h2>Students</h2> <table border="1">
<tr bgcolor="#9acd32"> <th>Roll No</th> <th>First Name</th>
<th>Last Name</th> <th>Nick Name</th> <th>Marks</th>
</tr>
<!-- for-each processing instruction
Looks for each element matching the XPAth expression -->
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<xsl:for-each select="class/student"> <tr>
<td>
<!-- value-of processing instruction
process the value of the element matching the XPath
expression -->
<xsl:value-of select="@rollno"/> </td>
<td><xsl:value-of select="firstname"/></td> <td><xsl:value-of
select="lastname"/></td> <td><xsl:value-of
select="nickname"/></td> <td><xsl:value-of
select="marks"/></td> </tr>
</xsl:for-each> </table> </body> </html> </xsl:template>
</xsl:stylesheet>
students.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="students.xsl"?>
<class>
<student rollno="393"> <firstname>Dinkar</firstname>
<lastname>Kad</lastname> <nickname>Dinkar</nickname>
<marks>85</marks> </student>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<student rollno="493"> <firstname>Vaneet</firstname>
<lastname>Gupta</lastname> <nickname>Vinni</nickname>
<marks>95</marks> </student>
<student rollno="593"> <firstname>Jasvir</firstname>
<lastname>Singh</lastname> <nickname>Jazz</nickname>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<marks>90</marks>
</student>
</class>
Result:
Thus sorting of student details according to rollno linking of xsl
with xml document is successfully executed.
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.
4.Display the result. 5.Stop the program.
Program Codings:
Inherit_Single.java
public class Inherit_Single {
protected String str;
Inherit_Single() {
str = "Java ";
cseitquestions.blogspot.in | cseitquestions.blogspot.in |
cseitquestions.blogspot.in
}
}
class SubClass extends Inherit_Single {
SubClass() {
str = str.concat("World !!!");
}
void display()
{
System.out.println(str);
}
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
}
class MainClass {
public static void main (String args[]){ SubClass obj = new
SubClass();
obj.display();
}
}
Result:
Thus the single inheritanve was executed successfully.
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
10.Simple application to access database using JDBC
Aim:
To creating the simple application to access database using JDBC.
Algorithm:
1.Start the program.
JDBC driver would be loaded;
3. Database Connection object would be created from using the
DriverManager (using the database driver loaded in the first step);
4.Statement object would be created using the Connection object;
5.SQL Select statement would be executed using the Statement
object, and a ResultSet would be returned;
6.The ResultSet would be used to step through (or iterate through) the
rows returned and examine the data.
7.Stop the program.
Program:
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
JDBCSample.java
import java.sql.*;
public class JDBCSample {
public static void main( String args[]) {
String connectionURL =
"jdbc:postgresql://localhost:5432/movies;user=java;password=samples"; //
Change the connection string according to your db, ip, username and
password
try {
Load the Driver class. Class.forName("org.postgresql.Driver");
If you are using any other database then load the right driver here.
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
//Create the connection using the static getConnection method
Connection con = DriverManager.getConnection (connectionURL);
//Create a Statement class to execute the SQL statement
Statement stmt = con.createStatement();
//Execute the SQL statement and get the results in a Resultset
ResultSet rs = stmt.executeQuery("select moviename, releasedate
from movies");
Iterate through the ResultSet, displaying two values
for each row using the getString method
while (rs.next())
System.out.println("Name= " + rs.getString("moviename") + "
Date= " + rs.getString("releasedate"));
}
catch (SQLException e) { e.printStackTrace();
}
catch (Exception e) { e.printStackTrace();
}
finally {
// Close the connection con.close();
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
}
}
}
Result:
Thus the simple application to access data base using JDBC.
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
11.Manipulating Database and SQL
Aim:
To write a program to manipulating Database and SQL.
Algorithm:
1.Importing java.sql package 2.Load and register JDBC driver.
3.Establishing a connection. 4.Creating a statement.
5.Execute SQL statement and retrive result. 6.Close connection.
7.Stop the program.
Program coding:
//import statements...
public class Main {
private static final String JDBC_DRIVER =
"com.mysql.jdbc.Driver"; private static final String
DATABASE_URL = "jdbc:mysql://localhost/hr";
private static final String USERNAME = "admin"; private static
final String PASSWORD = "secret"; public static void
createTable(){
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
Connection connection = null; Statement statement = null; try {
Class.forName(JDBC_DRIVER);
connection = DriverManager.getConnection(DATABASE_URL,
USERNAME,
PASSWORD);
statement = connection.createStatement();
//boolean b=statement.execute("DROP TABLE IF EXISTS
emp"); boolean b=statement.execute("CREATE TABLE emp(id
int primary key,name varchar(15),department int,salary
int,location varchar(20))"); if(b==true)
System.out.println("Tables created..."); } catch (SQLException sqlEx) {
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
sqlEx.printStackTrace();
System.exit(1);
} catch (ClassNotFoundException clsNotFoundEx) {
clsNotFoundEx.printStackTrace();
System.exit(1); } finally {
try { statement.close(); connection.close();
} catch (Exception e) { System.exit(1);
}
}
}
public static void createEmployee(int id, String name, int dept, int
sal, String loc){
Connection connection = null; PreparedStatement
preparedStatement = null; try {
Class.forName(JDBC_DRIVER);
connection = DriverManager.getConnection(DATABASE_URL,
USERNAME,PASSWORD);
preparedStatement = connection.prepareStatement("INSERT
INTO emp VALUES(?,?,?,?,?)");
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
preparedStatement.setInt(1, id); preparedStatement.setString(2, name);
preparedStatement.setInt(3, dept); preparedStatement.setInt(4, sal);
preparedStatement.setString(5, loc); boolean
b=preparedStatement.execute(); if(b==true)
System.out.println("1 record inserted...");
} catch (SQLException sqlEx) { sqlEx.printStackTrace();
System.exit(1);
} catch (ClassNotFoundException clsNotFoundEx) {
clsNotFoundEx.printStackTrace();
System.exit(1); } finally {
try {
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
preparedStatement.close();
connection.close();
} catch (Exception e) { System.exit(1);
}
}
}
public static void updateSalary(int id, int raise){ Connection
connection = null; PreparedStatement preparedStatement = null;
try {
Class.forName(JDBC_DRIVER);
connection = DriverManager.getConnection(DATABASE_URL,
USERNAME,PASSWORD);
preparedStatement = connection.prepareStatement("UPDATE
emp SET salary=salary+? WHERE id=?");
preparedStatement.setInt(1, raise); preparedStatement.setInt(2, id);
boolean b=preparedStatement.execute(); if(b==true)
System.out.println("$"+raise+" raised for emp id="+id);
} catch (SQLException sqlEx) { sqlEx.printStackTrace();
System.exit(1);
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
} catch (ClassNotFoundException clsNotFoundEx) {
clsNotFoundEx.printStackTrace();
System.exit(1); } finally {
try { preparedStatement.close(); connection.close();
} catch (Exception e) { System.exit(1);
}
}
}
public static void deleteEmployee(int id){ Connection connection
= null; PreparedStatement preparedStatement = null; try {
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
Class.forName(JDBC_DRIVER);
connection = DriverManager.getConnection(DATABASE_URL,
USERNAME,PASSWORD);
preparedStatement = connection.prepareStatement("DELETE
FROM emp WHERE id=?");
preparedStatement.setInt(1, id)
boolean b=preparedStatement.execute(); if(b==true)
System.out.println("1 record deleted...");
} catch (SQLException sqlEx) { sqlEx.printStackTrace();
System.exit(1);
} catch (ClassNotFoundException clsNotFoundEx) {
clsNotFoundEx.printStackTrace();
System.exit(1); } finally {
try { preparedStatement.close(); connection.close();
} catch (Exception e) { System.exit(1);
}}}
public static void readEmployees() { Connection connection = null;
Statement statement = null;
try { Class.forName(JDBC_DRIVER);
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
connection = DriverManager.getConnection(DATABASE_URL,
USERNAME,
PASSWORD);
statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT * FROM
emp"); ResultSetMetaData metaData = resultSet.getMetaData();
int noCols = metaData.getColumnCount(); for (int i = 1; i <= noCols; i++) {
if (i != 3) System.out.printf("%-10s\t",
metaData.getColumnName(i).toUpperCase());
}
System.out.println(); while (resultSet.next()) {
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
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);
} catch (ClassNotFoundException clsNotFoundEx) {
clsNotFoundEx.printStackTrace();
System.exit(1);
} finally { try {
statement.close();
connection.close();
} catch (Exception e) { System.exit(1);
}
}
}
public static void readEmployee(int id) { Connection connection =
null; Statement statement = null;
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
try { Class.forName(JDBC_DRIVER);
connection = DriverManager.getConnection(DATABASE_URL,
USERNAME,
PASSWORD);
statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT *
FROM emp WHERE id="+id);
ResultSetMetaData metaData = resultSet.getMetaData(); int noCols =
metaData.getColumnCount();
for (int i = 1; i <= noCols; i++) { if (i != 3) System.out.printf("%10s\t",
metaData.getColumnName(i).toUpperCase());
}
System.out.println();
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
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);
} catch (ClassNotFoundException clsNotFoundEx) {
clsNotFoundEx.printStackTrace();
System.exit(1);
} finally { try {
statement.close();
connection.close();
} catch (Exception e) { System.exit(1);
}
}
}
public static void main(String[] args) {
//createTable();
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
createEmployee(1234, "Larson", 123, 1200, "New Jersey");
createEmployee(5678, "Jones", 123, 1100, "New Jersey");
createEmployee(7890, "Kapil", 345, 1600, "Los Angeles");
createEmployee(2341, "Myers", 123, 1800, "New Jersey");
createEmployee(6784, "Bruce", 345, 2200, "Los Angeles");
createEmployee(9636, "Neumann", 123, 3200, "New Jersey");
updateSalary(1234, 1000);
createEmployee(1111, "Lee", 123, 4400, "New Jersey");
deleteEmployee(1111);
readEmployees();
readEmployee(6784);
}
}
Result:
Thus the manipulating theDatabaseand SQLsexecutedsuccessfully
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
12. Program using PHP database functions
Aim:
To write a program using PHP database functions
Algorithm:
1 . Start the program
2 . Open a connection to MySQL
3 . Specify the database you want to open
4 . Close the connection
5 . Stop the program
Program:
<?PHP
$user_name = "root"; $password = "";
$database = "addressbook"; $server = "127.0.0.1";
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
mysql_connect($server, $user_name, $password); print
"Connection to the Server opened";
?>
$db_found = mysql_select_db($database); if ($db_found) {
print "Database Found";
}
else {
print "Database NOT Found";
}
<?PHP
$user_name = "root"; $password = "";
$database = "addressbook"; $server = "127.0.0.1";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
if ($db_found) {
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
print "Database Found "; mysql_close($db_handle);
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
}
else {
print "Database NOT Found ";
}
?>
Result:
Thus the program using PHP database functions
executed successfully.
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
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.
2 . Install Apache Tomcat. At the time of installation, it will by-default
recognize JRE path. (under installed java location directory)
3 . Now Go-To: Start
Programs APACHE TOMCAT
MONITOR TOMCAT
4 . An icon will appear on the taskbar, this icon will automatically
appear after following above
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
5 . Click on that icon and START TOMCAT, you can see the
following dialog box:
6 . Now open Mozilla Firefox(or any other browser)
7 . Type http://localhost:8080/ on address bar and press enter.
The same can be seen here:
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
(or navigate where you have installed APACHE TOMCAT)
10 . Open web-apps and ?opy your projector ?ake new folder which
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
you want to run in JSP. Example: amit2012PROJECT Now, go
back :
Tomcat Root
Copy
Paste
Web-inf from root
this ?eb-infin your project folder i.e. amit2012PROJECT
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.");
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
%>
<%-- END --%>
</body>
</html>
It includes HTML tags and encloses a JSP scriptlet which is a
fragment of Java code that is run when the user requests the page.
12 . Now for running your folder [ Eg. amit2012PROJECT as
shown above]
http://localhost:8080/foldername.extension in any WebBrowser i.e:
http://localhost:8080/amit2012PROJECT/first.jsp
The Project will run successfully, as shown below:
Now, you can successfully try running JSP with ApacheTomcatServer.
Program:
INDEX.JSP:
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<%@page import="java.sql.ResultSet"%> <%@page
import="java.sql.Statement"%>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<%@page import="java.sql.Connection"%> <%@page
import="java.sql.DriverManager"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-
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();
ResultSet rs=st.executeQuery("select * from answers;");
while(rs.next()){
String a="a"+i; q=rs.getString(1); ch1=rs.getString(2); ch2=rs.getString(3);
ch3=rs.getString(4);
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
%>
<div id="ques" name="que"><%=q%></div>
<input type="radio" style="display:none;" name=<%=a%> value=""
checked="checked" />
<input type = "radio" name =<%=a%> value =<%=ch1%> /><
%=ch1%>
<input type = "radio" name =<%=a%> value =<%=ch2%> /><
%=ch2%>
<input type = "radio" name =<%=a%> value =<%=ch3%> /><
%=ch3%>
<%
i++; } %>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<input type="submit" value="submit" />
</form>
</body>
</html>
RESULT.JSP
<%@page import="java.sql.ResultSet"%> <%@page
import="java.sql.ResultSet"%> <%@page
import="java.sql.Statement"%> <%@page
import="java.sql.DriverManager"%> <%@page
import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-
8">
<title>Result</title>
</head>
<body><%
int i=0,count=0;
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
String ans[]=new String[120];//answer from user String ans_ser[]=new
String[120];//answer from server
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
on=DriverManager.getConnection("jdbc:odbc:exam1","",""); Statement
st=on.createStatement();
ResultSet rs=st.executeQuery("select * from answers;");
while(rs.next()){
String a="a"+i; ans[i]=request.getParameter(a); ans_ser[i]=rs.getString(5);
if(ans[i].equals(ans_ser[i])){
count++;
}
i++;
}
%><br><br><br><br>
<center>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<h1>MARKS : <%=count%></h1> </center>
</body>
</html>
Result:
Thus the installation of Tomcat and use JSP was
executed successfully.
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
14. Reading and Writing the files using .Net
Aim:
To read and write the files using .Net
Algorithm:
1Start the program 2Open new file
3Read and write the file using .Net 4Execute the file
5Stop the program 6
Program:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="ReadWriteTextCSharp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional.dtd">
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<html xmlns="http://www.w3.org/1999/xhtml" > <head
runat="server">
<title>Reading and writing to the file using ASP.NET
C#</title> <style type="text/css">
<!-- body {
margin-left: 0px; margin-top: 0px; margin-right: 0px; marginbottom: 0px;
}
a:link {
color: #0000FF;
}
a:visited {
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
color: #0000FF;
}
a:hover {
color: #0000FF; text-decoration: none;
}
a:active {
color: #0000FF;
}
.basix {
font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px;
}
.header1 {
font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px;
font-weight: bold; color: #006699;
}
.lgHeader1 {
font-family: Arial, Helvetica, sans-serif; font-size: 18px;
font-weight: bold; color: #0066CC;
background-color: #CEE9FF;
}
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
--> </style>
</head>
<body>
<br />
<table align="center" border="0" cellpadding="0"
cellspacing="0" style="position: static"
width="752">
<tr bgcolor="#5482fc"> <td colspan="4">
<img height="1" src="/media/spacer.gif" width="1" /></td>
</tr>
<tr>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<td bgcolor="#5482fc" width="1"> <img alt="Server Intellect"
height="1"
src="media/spacer.gif" width="1" /></td> <td width="250">
<a href="http://www.serverintellect.com">
<img alt="Server Intellect" border="0" height="75"
src="media/logo.gif" width="250" /></a></td>
<td bgcolor="#3399ff" width="500">
<a href="http://www.serverintellect.com">
<img alt="Server Intellect" border="0" height="75"
src="media/headerR1.gif" width="500" /></a></td>
<td bgcolor="#5482fc" width="1"> <img alt="Server Intellect"
height="1"
src="media/spacer.gif" width="1" /></td> </tr>
<tr bgcolor="#5482fc"> <td colspan="4">
<img height="1" src="media/spacer.gif" width="1" /></td>
</tr>
</table> <br />
<table align="center" bgcolor="#5482fc" border="0"
cellpadding="5" cellspacing="1"
style="position: static; width: 692px;"> <tr>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<td align="center" class="lgHeader1" height="50"> Reading and
writing to file using ASP.NET and
C#.NET</td>
</tr>
</table> <br /> <br />
<fieldset style="width: 804px" align="center">
<legend>Reading and writing to file</legend> <div align="left"
style="text-align: center">
<form id="form1" runat="server">
<table width="600" border="0" align="center" cellpadding="5"
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
cellspacing="1" bgcolor="#cccccc"> <tr>
<td bgcolor="#eeeeee" class="header1"> <fieldset>
<legend>ReadWriteTextCsharp</legend> <div>
<asp:Label ID="Label1" runat="server" Text="Enter path of file to
be examined and click Display"></asp:Label><br />
<asp:TextBox ID="txtBoxInput" runat="server"
Width="451px"></asp:TextBox>
<asp:Button ID="buttonDisplay" runat="server" Text="Display"
OnClick="buttonDisplay_Click" /><br />
<fieldset>
<legend>Content of file</legend>
<asp:Label ID="Label2" runat="server" Text="You can edit the
content and save as a file."></asp:Label><br />
<table>
<tr>
<td>
<asp:TextBox ID="textBoxContents" runat="server" tabIndex="0"
height="200px" textMode="MultiLine"
width="450px"></asp:TextBox> </td>
</tr>
</table>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<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>
<asp:Button ID="buttonSave" runat="server" Text="Save As"
Width="66px" OnClick="buttonSave_Click" /></fieldset> </fieldset>
</div>
</fieldset>
</td>
</tr>
</table>
</form>
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
<br /> </div> </fieldset>
<br /><br />
<table align="center" cellpadding="0" cellspacing="0"
style="position: static" width="500">
<tr>
<td align="center" class="basix" height="50"> <strong>Power.
Stability. Flexibility.</strong><br /> Hosting from <a
href="http://www.serverintellect.com">Server Intellect</a><br />
<br />
For more ASP.NET Tutorials visit <a
href="http://www.dotnettutorials.com">www.dotnettutorials.com</a><br
/></td>
</tr>
</table>
</body>
</html>
Default.aspx.cs
using System; using System.Data;
using System.Configuration; using System.Collections; using
System.Web;
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
using System.Web.Security; using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts; using
System.Web.UI.HtmlControls;
using System.IO;
public partial class ReadWriteTextCSharp : System.Web.UI.Page
{
protected void buttonDisplay_Click(object sender, EventArgs e)
{
string FilePath;
FilePath = txtBoxInput.Text; if (File.Exists(FilePath))
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
{
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
{
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
Response.Write("<script language='javascript'>window.alert('Please enter
file name');</script>");
}
}
else
{
Response.Write("<script language='javascript'>window.alert('Folder not
found');</script>");
}
}}
Result:
Thus the reading and writing the files using .net executed
successfully
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
15.Write a program to implement web service for
calculator application
Aim:
To Write a program to implement web service for calculator
application
Algorithm:
1Create new project
2Select ASP.NET Empty Web Application 3Give a name to your
project and click ok button
4Go to Solution Explorer and right click at your project 5Select
Add New Item and select Web Service application 6Give it
name and click ok button
Program:
using System;
using System.Collections.Generic; using System.Linq;
using System.Web;
using System.Web.Services;
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
namespace calc
{
[WebService(Namespace = "mycalculatorexample.org")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class CalcWebService : System.Web.Services.WebService
{
[WebMethod]
public string calculate(string first, string second, char sign)
{
string result; switch (sign)
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
{
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 '%':
{
cseitquestions.blogspot.in | cseitquestions.blogspot.in | cseitquestions.blogspot.in
result = (Convert.ToInt32(first) %
Convert.ToInt32(second)).ToString(); break;
}
default:
result = "Invalid"; break;
}
return result;
}
}
}
Result:
Thus the implementation of web service for calculator application
executed successfully.
Sponsor Documents