Web Technology Practical
Web Technology Practical
NO:1
FIBONACCI SERIES
DATE:
AIM:
To write a JavaScript program to find fibonacci series.
PROCEDURE:
1. Open the notepad and type the program.
2. Declare the variables.
3. By using prompt () method displays a dialog box that prompts the user for input.
4. After entering an input value the user will have to click “ok” or “cancel” to proceed.
5. If the user clicks “ok” the box returns input value. If the user clicks “ cancel” the box returns null.
6. The parseInt () method parses a value as a string and return the integer.
7. To print statements the following methods were used.
Document.write () does not add a new line after each statement
Document.writeln () add a new line after each statement
8. Using for loop find Fibonacci series.
9. Save the program as Fibonacci.html.
10. Finally run the program though browser.
1
PROGRAM:
<html>
<body>
<h1>*****fibonacci series*****</h1>
<script>
var n1=0,n2=1,n3,i;
var num=parseInt (prompt("enter the limit of fibonacci series"));
document.writeln("fibonacci series is:");
document.writeln("<br>"+n1);
document.writeln("<br>"+n2);
for(i=3;i<=num;i++)
{
n3=n1+n2;
document.writeln("<br>"+n3);
n1=n2;
n2=n3;
}
</script>
</body>
</html>
2
OUTPUT:
3
RESULT:
Thus the program was executed successfully.
4
EX.NO:2
PALINDROME
DATE:
5
PROGRAM:
<html><body>
<h1>****check palindrome or not****</h1>
<script>
function palindrome()
{
var givenstring=prompt("enter the string:");
document.writeln("<br>"+"the givenstring is:",givenstring);
var arraystring=givenstring.split('');
document.writeln("<br>"+"the split()string is :",arraystring);
var reversestring=arraystring.reverse();
document.writeln("<br>"+"the reverse()string is:",reversestring);
var finalstring=reversestring.join('');
document.writeln("<br>"+"the join()string is:",finalstring);
document.writeln("<br>");
if(givenstring==finalstring)
{document.writeln("<br>"+"the string is palindrome");}
else
{
document.writeln("<br>"+"the string is not palindrome");
}}
palindrome();
</script>
</body></html>
6
OUTPUT:
7
8
RESULT:
Thus the program was executed successfully.
9
EX.NO:3 FORM VALIDATION
DATE:
AIM:
10
PROGRAM:
<html>
<head>form validation</head>
<body>
<form name="login">
username<input type="text"name="userid"/>
password <input type="password"name="pswrd"/>
<input type="button"onclick="check(this.form)"value="login"/>
<button type="reset"value="Reset">Reset</button>
</form>
<script language="javascript">
function check(form)
{
if(form.userid.value=="kaleeswari"&& form.pswrd.value=="c0s39951")
{
alert("registered your password or username")
}
else
{
alert("error password or username")
}
}
</script>
</body>
</html>
11
OUTPUT:
12
13
RESULT:
Thus the program was executed successfully.
14
EX:NO:04
POPUP WINDOW CREATION
DATE:
AIM:
To write a JavaScript program to create popup window.
PROCEDURE:
1. Open the notepad and type the program
2. JavaScript has three kind of popup boxes: alert box, confirm box and prompt box
3. An alert box is used to give a message to the users, when an alert box pops up, the user have to click “ok”
to proceed.
4. A confirm box is used if you want the user to verify or accept something. when a confirm box pops up,
the user click either “ok” or “cancel” to proceed.
5. If the user click “ok”, the box return true. If the user clicks “cancel”, the box return false.
6. A prompt box is used if you want the user to input a value before entering a page. When a prompt box
pops up, the user will have to click either “ok” or “cancel” to proceed after entering an input value.
7. If the user clicks ok the box return the input value. If the user clicks cancel the box return null.
8. The on click event occurs when the user clicks any one of two buttons. In this event the function1() or
function2() is called and executed.
9. Save the program as popup.html.
10. Finally run the program through browser.
15
PROGRAM:
<html>
<body>
<h1>*****confirm box alert box prompt box******</h1>
<button onclick="function1()">"to know the confirm box try if"</button>
<button onclick="function2()">"to know the prompt box try if"</button>
<script>
function function1()
{
if(confirm("press the putton"))
{
alert("ok");
}
else
{
alert("cancal");
}
}
function function2()
{
var user=prompt("enter the user name");
if(user=="admin")
{
alert("login succesfully");
}
else
{
alert("login failed");
}
}
</script>
</body>
</html>
16
OUTPUT:
17
18
RESULT:
Thus the program was executed successfully.
19
EX:NO:5
EVENT HEADLER
DATE:
AIM:
To write a JavaScript program to handle events.
PROCEDURE:
1. Open the notepad and type the program.
2. The onmuseover event occurs when mouse pointer is moved on to an element<p>. in this event the
function f1() is called.
3. The onfocus event occurs when an element get focus. Which is most often used with<input>.in this event
the function f2() is called.
4. The onclick event occurs when the user clicks on an element. In this event the function f3() is called.
5. The onkeydown event occurs when a key is pressed. In this event the function f4() is called.
6. Save the program as event.html.
7. Finally run the program through browser.
20
PROGRAM:
<html>
<head>
<script>
function f1()
{
alert("on mouse event");
}
function f2()
{
document .getElementById("text1").style.background="red";
}
function f3()
{
alert("I am a programmer");
}
function f4()
{
alert("you pressed the key");
}
</script>
</head>
<body>
<h1>JAVASCRIPT EVENTS</H1>
<form action ="address.html">
<p onmouseover="f1()">Keep cursor me</p>
<br>
<br>
enter your name :<input type="text"id="text1"onfocus="f2()">
<br>
<br>
<input type="button"onclick="f3()"value=" i am click here to know who am i">
21
<br>
<br>
enter something here:<input type="text"onkeydown="f4()">
<br>
<br>
<button type=submit>submit</button>
</from>
</body>
</html>
22
OUTPUT:
23
24
RESULT:
Thus the program was executed successfully
25
EX.NO:6
DROP DOWN LIST
DATE:
AIM:
To write a JavaScript program to remove items from dropdown list.
PROCEDURE:
1. Open the notepad and type the program.
2. Create a drop-down list with 5 options.
3. The <select>element is used to create a drop-down list.
4. The<option> tags inside the <select> element define the available options in the drop-down list .
5. The onclick event occurs when the user clicks remove button. In this event the function item() is called.
6. In the item(0 function declare the variable and get the value for the variable by
document.getElementById() method which return an element with a specified value.
7. The selectedIndex property sets or returns the index of the selected option in drop-down list and the index
starts at(0.
8. The remove() method removes the selected element.
9. Save the program as dropdown.html.
PROGRAM:
<html>
26
<head>
<script>
function item()
{
var c=document.getElementById("color");
c.remove(c.selecteIndex);
}
</script>
</head>
<body>
<h1>****remove items from drop down list****</h1>
<select id="color">
<option>red</option>
<option>blue</option>
<option>green</option>
<option>purple</option>
<option>yellow</option>
</select>
<input type="button"onclick="item()"value="remove">
</body>
</html>
27
OUTPUT:
28
RESULT:
Thus the program was executed successfully.
29
EXNO:7
DISPLAY A RANDOM IMAGE
DATE:
AIM:
To write a JavaScript program to display a random image.
PROCEDURE:
1. Open the notepad and type the program.
2. The onclick event occurs when the user click button. In this event function.
selInterval(randomimage,2000)is called.
3. The setInterval() method calls a function random image at specified intervals(in
milliseconds).2second=2000 milliseconds.
4. In randomimage() method create an array of four images, and stuff it into the variable r
5. The variable number gets the value of a math expression.
6. Math.random generates a random number between 0 and 1,which is multiplied by r.length, which is the
number of items in the array (in this case, it’s 4). Math.floor rounds the result down to an integer.
7. The source of the image result is set based on the array r, and the value at this moment is dependent on the
value of number.
8. Save the program as randomimage.html.
9. Finally run the program through browser.
30
PROGRAM:
<html>
<head>
<script>
function randomimage()
{
var r=new Array("image1.jpg","image2.jpg","image3.jpg");
var number=Math.floor(Math.random()*r.length);
return document.getElementById("result").src=r[number];
}
</script>
</head>
<body>
<img src="image1.jpg"height="500"width="500"id="result">
<br><br>
<button onclick="setInterval(randomimage,1000)">click</button>
</body>
</html>
31
OUTPUT:
32
RESULT:
Thus the program was executed successfully.
33
EX:NO:08 E-MAIL ADDRESS VALIDATION
DATE:
AIM:
To write a JavaScript program to display a random image.
PROCEDURE:
1. Open the notepad and type the program.
2. The onclick event occurs when the user click button. In this event function validate() is called.
3. In validate() method create a variable text, and get the value.
4. To get a vali email id we use aregular expression /^([A-Za-z0-9\.-])+@([a-z]{5}).9[a-z]{3})$/
5. The test() method.tests for a match in a string. if it finds a match, it returns true, otherwise it returns false.
6. Save the program as emailvalidation.html.
7. Finally run the program through browser.
34
PROGRAM:
<html>
<head>
<script>
function validate()
{
var text=document.getElementById("text1").value;
var regx=/^([A-Za-z0-9\.-])+@([a-z]{5}).([a-z]{3})$/;
if(regx.test(text))
{ alert("VALID");}
else
{
alert("NOT VALID");
}}
</script>
</head>
<body>
<form>
<h1>***valid email address***</h1><br>
<input type="text"id="text1"placeholder="Email"><br><br>
<button onclick="validate()">submit</button>
</form>
</body>
</html>
35
OUTPUT:
36
RESULT:
Thus the program was executed successfully.
37
EX:NO:09
ADD CONTENT OF ANOTHER JSP FILES
DATE:
AIM:
To write a JSP program to add the contents of another JSP file using @ include directive.
PROCEDURE:
1. Open the notepad and type the program.
2. Save the program as main.jsp in c:\programfiles\apache software foundation\tomcat9.0\wed
apps\kalees\main.jsp.
Flooder name=kalees, file name =main.jsp.
3. In main.jsp include the file header.jsp and footer.jsp by using JSP include directive.
4. The JSP include directive is used to include static resource into the current JSP page at translation time.
Example:%@include file=”header.jsp”%.
5. Finally run the program though browser by type localhost:8080/main.jsp.
6. If the tomcat home page does to come then do the following steps.
i. Open the command prompt and type netstat–ano|findstr 8080
ii. End the task which come in command prompt.
7. http://localhost:8080/austin/main.jsp.
38
PROGRAM:
Main.jsp
<html>
<body>
<h1>****** jsp files*****</h1>
<h2>****** this is main jsp file****</h2>
<br><br><br><br>
<%@include file ="header.jsp"%>
<br><br><br><br>
<%@include file ="footer.jsp"%>
</body>
</html>
Header.jsp
<html>
<body>
<h2>*** this is header jsp file*****</h2>
<br><br>
<%out.println ("chess was invented in india");%>
<br><br>
<%out.println ("prard to be an indian");%>
<br><br>
</body>
</html>
Footer.jsp
<html>
<body>
<h2>****** this is footer jsp file****</h2>
<br><br>
<%out.println ("life is all about balance");%>
</body>
</html>
39
OUTPUT:
40
RESULT:
Thus the program was executed successfully.
41
EX:NO:10
CHECK PRIME OR NOT
DATE:
AIM:
To write a JSP program to check whether the given number is prime or not.
PROCEDURE:
1. Open the notepad and type the program.
2. Save the program as prime1.jsp in c:\programfiles\apache software foundation\tomcat9.0\wed
apps\kalees\prime.jsp.
42
PROGRAM:
<html>
<body>
<h1>*****prime number*****</h1>
<%
int num=Integer.parseInt(request.getParameter("id"));
int flag=0;
for(int i=2;i<num;i++)
{
if(num%i==0)
{
flag=1;
break;
}}
if(flag==0)
{
out.println("this is a prime number");
}
else
{
out.println("this is not prime number");
}
%>
</body></html>
43
Output:
44
RESULT:
Thus the program was executed successfully.
45
EX:NO:11
FORWARD ONE JSP FILE TO ANOTHER
DATE:
AIM:
To write a JSP program to forward one JSP file to another JSP file using forward action.
PROCEDURE:
1. Open the notepad and type the program.
2. Save the program as prime1.jsp in c:\programfiles\apache software foundation\tomcat9.0\wed apps\
3. In forwardpage.jsp we use JSP forward action tag to forward a request to another JSP. Request can be
forwarded with or without parameter.
4. In this program we are passing 2 parameter along with forward and later we are displaying them on the
forwarded page. In order to fetch the parameters on result.jsp page we are using get Parameter method of
request implicit object.
5. Finally run the program though browser by type localhost:800/au/forwardpage.jsp.
46
PROGRAM:
forwardpage.jsp
<html>
<body>
<h1>*****forward one JSP file to another JSP file**</h1>
<% out.println("before jsp forward action");%>
<h2>Middle of the jsp file</h2>
<jsp:forward page="result.jsp">
<jsp:param name="Studentname" value="kaleeswari"/>
<jsp:param name="Department" value="computer science"/>
</jsp:forward>
<% out.println("after JSP forward action");%>
</body></html>
Result.jsp
<html>
<body>
</h1>***** save tree****</h1><br>
<% out.println("plant a tree today plan for a good future");%>
<p>
<% out.println(request.getParameter("Studentname"));%>
<br>
<% out.println(request.getParameter("Department"));%>
</body>
</html>
47
Output:
48
RESULT:
Thus the program was executed successfully.
49
EX:NO:12
WORK WITH PAGE AND FORMS
DATE:
AIM:
To write the Asp.Net program to work with page and forms.
PROCEDURE:
3. In source mode of WebForm1 type the hello world message by using Response.Write() method
50
PROGRAM
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.vb"
Inherits="WebApplication28.WebForm1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<%
Response.Write("hello world");
%>
</div>
</form>
</body>
</html>
51
OUTPUT:
52
RESULT:
Thus the program was executed successfully.
53
EX.NO:13 REGISTRATION FORM VALIDATION
DATE:
AIM:
PROCEDURE:
4. In first column type the field names shown in picture. AlignJustify Right
5. In second column of each row drag and drop text box from Toolbox except Gender field row
54
6. In second column Gender field row drag and drop Dropdown list from Toolbox. Edit itemsGive
the list data
7. drop Drag and RequiredFieldValidator from Toolbox in third column of each row
55
8. Give the ErrorMessage like “UserName is required” in properties. Likewise give the ErrorMessage
for all the fiels which is shown in below picture
56
10. Connect RequiredFieldValidator with corresponding text box
Click RequiredFieldValidator and choose ControlToValidate in properties from that
choose the corresponding text box. Do the same for all RequiredFieldValidator
11. Drag and drop CompareValidator from Toolbox and place third column of Retype Password field
row.
57
12. Give the ErrorMessage like “Both password must be same” in properties. Click CompareValidator
and click ControlToValidate in properties from that choose the corresponding text box
13. Click CompareValidator and click ControlToCompare in properties from that choose the
corresponding text box
58
14. Drag and drop RegularExpressionValidator from Toolbox and place third column of Email id field
row. Give the ErrorMessage like “you must enter the valid Email id” in properties.
59
15. Select RegularExpressionValidator and click ValidationExpression in properties from that choose
Internet e-mail address option
16. Drag and drop Submit and Reset Button from Toolbox
60
17. Double click the Submit button and place the following code in Button1_onclick () method
document.write(“Your Registration is successfull”);
61
OUTPUT:
62
RESULT:
Thus the program was executed successfully.
63
EX.NO:14
READ STUDENT DETAILS FROM XML FILE
DATE:
AIM:
PROCEDURE:
1. FilenewprojectConsole Applicationok
64
3. Give basic details about students in the Xml file named as XMLFile1.xml
4. In Program.cs file the XmlTextReader class provides read-only access to a stream of XML data.
65
PROGRAM:
XMLFile1.xml
<student>
<name>Bhuvana</name>
<regno>cs101</regno>
<year>III</year>
<dept>B.Sc(cs)</dept>
<phno>1234567890</phno>
<city>Theni</city>
</student>
<student>
<name>Muthu</name>
<regno>cs102</regno>
<year>II</year>
<dept>B.Sc(cs)</dept>
<phno>0908765432</phno>
<city>Madurai</city>
</student>
<student>
<name>Suruthi</name>
<regno>cs103</regno>
<year>III</year>
<dept>B.Sc(cs)</dept>
<phno>2345678910</phno>
<city>Theni</city>
</student>
</studentdetails>
66
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("*****STUDENT DETAILS*****");
XmlTextReader xdoc = new XmlTextReader("C:\\Users\\USER\\Documents\\Visual Studio
2010\\Projects\\ConsoleApplication2\\ConsoleApplication2\\XMLFile1.xml");
while (xdoc.Read())
{
if (xdoc.NodeType == XmlNodeType.Element && xdoc.Name == "name")
{
string s1 = xdoc.ReadElementString();
Console.WriteLine("Name = " + s1);
}
if (xdoc.NodeType == XmlNodeType.Element && xdoc.Name == "regno")
{
string s2 = xdoc.ReadElementString();
Console.WriteLine("Regno = " + s2);
}
if (xdoc.NodeType == XmlNodeType.Element && xdoc.Name == "year")
{
string s3 = xdoc.ReadElementString();
Console.WriteLine("Year = " + s3);
67
}
if (xdoc.NodeType == XmlNodeType.Element && xdoc.Name == "dept")
{
string s4 = xdoc.ReadElementString();
Console.WriteLine("Dept = " + s4);
}
if (xdoc.NodeType == XmlNodeType.Element && xdoc.Name == "phno")
{
string s5 = xdoc.ReadElementString();
Console.WriteLine("Phno = " + s5);
}
}
}
}
}
68
OUTPUT:
69
RESULT:
Thus the program was executed successfully.
70
EX.NO:15
DISPLAY VEHICLE DETAILS IN TREE VIEW CONTROL
DATE:
AIM:
PROCEDURE:
1. Filenewproject
71
3. From toolbox drag and drop the treeview to Default.aspx design view
72
4. From toolbox drag and drop the XmlDataSource to Default.aspx design view
73
5. Choose XML File. Click add
<car_catalog>
<car>
<name>corrolla</name>
<model>2015</model>
<type>sedan</type>
<price>450000</price>
</car>
<car>
<name>civic</name>
<model>2019</model>
<type>sedan</type>
<price>500000</price>
</car>
<car>
<name>passo</name>
74
<model>2021</model>
<type>hatackchb</type>
<price>800000</price>
</car>
<car>
<name>land cruiser</name>
<model>2022</model>
<type>suv</type>
<price>900000</price>
</car>
</car_catalog>
75
7. In Default.aspx design view click XmlDataSourceconfigure Data SourceXMLFile1.xmlOk
76
9. In TreeView DataBindings Editor
Click car_catalogGive TextField value #Name
Click carGive TextField value #Name
77
OUTPUT:
78
RESULT:
Thus the program was executed successfully.
79
EX.NO:16
AN APPLICATION USING MENU SERVER CONTROL
DATE:
AIM:
PROCEDURE:
80
3. In Design mode of Master Page Drag and Drop Menu from Navigation of tool box
81
5. Create Web Forms for all menu items. Enable Select master page option for all Web Forms
6. Click the menuEdit Menu ItemsSelect menu item one by one and choose corresponding
NavigateUrl
82
7. Give color for the text by choose style propertyfontcolor
83
OUTPUT:
84
85
RESULT:
Thus the program was executed successfully.
86
EX.NO:17
STUDENT DATABASE USING SQL DATASOURCE CONTROL
DATE:
AIM:
Write an ASP.Net program to create student database using sql data source control.
PROCEDURE:
DatabaseaddYes
87
6. In Server Explorer click TablesAdd New Table
88
8. To insert rows in Table click Table1Show Table Data
89
10. Click SqlDataSourceConfigure Data SourceNew Connection Database1.mdfNextFinish
91
RESULT:
Thus the program was executed successfully.
92
EX.NO:18 DISPLAY EMPLOYEE DETAILS USING SITEMAP DATA SOURCE
DATE:
AIM:
Write an ASP.Net program to display employee details using sitemap data source.
PROCEDURE:
93
5. Right click WebApplication4 in Solution ExplorerAddNew ItemWeb Form (named as
WebForm2)add
6. In design view of WebForm2 insert table to store employee job details
94
7. Right click WebApplication4 in Solution ExplorerAddNew ItemWeb Form (named as
WebForm3)add
8. In design view of WebForm3 insert table to store employee personal details
95
10. In SiteMap xml file type the following code:
</siteMapNode>
</siteMap>
96
11. Right click tree viewchoose data source
97
OUTPUT:
98
Click the personal to know employee personal details
99
RESULT:
Thus the program was executed successfully.
100
EX.NO:19
DISPLAY PERSONAL DATABASE USING XML
DATE: DATA SOURCE
AIM:
PROCEDURE:
101
6. Select GridView click Auto Formatchoose Classicclick ok
102
9. Select XmlDataSource click Configure Data SourceBrowse Data filechoose
XMLFile1.xmlclick ok
103
OUTPUT:
104
RESULT:
Thus the program was executed successfully.
105
EX.NO:20
CREATE WEB PAGE FOR DEPATMENT
DATE:
AIM:
PROCEDURE
3. In Design mode of Master Page Drag and Drop Menu from Navigation of tool box
4. Right click the menuEdit Menu Items. In Menu Item Editor give menu names by edit the text
property
106
5. Create Web Forms for all menu items. Enable Select master page option for all Web Forms
6. Click the menuEdit Menu ItemsSelect menu item one by one and choose corresponding
NavigateUrl
107
OUTPUT
108
RESULT:
Thus the program was executed successfully.
109
EX.NO:21
SEND A MAIL
DATE:
AIM:
PROCEDURE:
3. In design mode of Default2.aspx insert the table with 3 rows and two columns
5. In the second column place 2 textboxes named as textbox1 and textbox2 and also place 1button
named as register by using text property
110
9. ON allow less secure apps
111
PROGRAM:
Default2.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Net;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "flasome2k22");
smtp.EnableSsl = true;
MailMessage msg = new MailMessage();
msg.Subject = "Hello " + TextBox1.Text + " Thanks for Register";
msg.Body = "Hi, Thanks For Your Registration, We will Provide You The Latest Update. Thanks";
string toaddress = TextBox2.Text;
msg.To.Add(toaddress);
string fromaddress = "<[email protected]>";
msg.From = new MailAddress(fromaddress);
try
{
112
smtp.Send(msg);
Label1.Text = "Your Email Has Been Registered with Us";
TextBox1.Text = "";
TextBox2.Text = "";
}
catch
{
throw;
}
}
}
113
OUTPUT:
After click the register button. The label displays the message
114
Message sent from the given mail id
115
RESULT:
Thus the program was executed successfully.
116