ONMOUSEOVER EVENT
EX.NO : 10
DATE :
AIM:
To write a java script code to count number
of times you move over a link or record.
HARDWARE REQUIREMENTS
1. Computer with Pentium processor.
SOFTWARE REQUIREMENTS:
- Notepad or any Editor
- Internet Explorer Web Browser
PROCEDURE:
1.
Open the
Notepad
2.
Type the
Html code and java script code in Notepad
3.
Save the
file with the extension.html or .htm
4.
Run the
Html document in any Web browser
5.
Verify
the output
HTML CODE & JAVA SCRIPT CODE:
mouse.html
<html>
<head>
<title>New
Page 1</title>
<script
type=text/javascript>
count=0
function linkcount()
{
count++
lc.innerText=count
}
</script>
</head>
<body>
<a
target="_self" href="red.html"
onmouseover="linkcount()">Red</a>
<p>
<font
face="Bodoni MT" color="#0000FF">
Number of times you
moved over a link >>
</font>
<font
face="Bodoni MT" color=#FF0000 id=lc>
</font>
</p>
</body>
</html>
red.html
<html>
<head>
<title>New
Page 1</title>
</head>
<body
bgcolor=red>
<b><font
color="#FFFFFF">Red
</font></b>
</body>
</html>
OUTPUT:
RESULT:
Thus the web page for onmouseover event
is designed, executed and the required output is obtained.
SENDING REQUEST TO JSP
EX.NO : 11
DATE :
AIM:
To write a
HTML document which sends the user request for open source item to JSP and gets the definition of open
source item.
HARDWARE
REQUIREMENTS:
- Computer with Pentium
processor
SOFTWARE
REQUIREMENTS:
- Notepad or any editor
- Apache Tomcat Server
5.0
- JDK 1.7
- Internet Explorer
PROCEDURE:
- Open the notepad or any
notepad.
- Edit the HTML coding
and save it with .html extension.
- Edit the JSP coding and
save it with .jsp extension.
- Save the both HTML and
JSP file in apache tomcat web server ROOT address.
- Run the tomcat server
using command prompt.
- Open the internet explorer.
In address bar give
http://localhost:8080/ follows filename with extension to run.
- Observe the output.
HTML AND
JSP CODE:
Open_src.html
<html>
<head><title>Chemistry
Item</title></head>
<body>
<form method=post action=item.jsp>
<p align="center">
Enter Your Open Source Item :
<input type="text" name="t1"
size="20">
<input type="submit"
value="Send" name="B1">
<input type="reset"
value="Clear" name="B2">
</p>
</form>
</body>
</html>
item.jsp
<%
String name[]={"Red Hat Linux ","PHP","PHYTHON","OSCAD","LATEX"};
String def[]={"Operating System", "Developing
Interactive Website", "Numerical Computation Software for Science and
Engg", "Software for Circuit Design” ,”Software for word processing
and spread sheet“};
String s1=request.getParameter("t1");
String s2=s1.toUpperCase();
int i;
for(i=0;i<10;i++)
{
if(s2.equals(name[i]))
{
out.print("THE DEFINITION FOR GIVEN ITEM
-- >def[i]);
break;
}
}
OUTPUT:
RESULT:
Thus the web page for Sending request to
JSP Page is designed, executed and the required output is obtained.
COOKIE MANIPULATION
EX.NO : 12
DATE
:
AIM:
To write a JSP code to manipulate cookies.
HARDWARE
REQUIREMENTS:
- Computer with Pentium
processor
SOFTWARE
REQUIREMENTS:
- Notepad or any editor
- Apache Tomcat Server
5.0
- JDK 1.7
- Internet Explorer
PROCEDURE:
- Open the notepad or any
notepad.
- Edit the HTML coding
and save it with .html extension.
- Edit the JSP coding and
save it with .jsp extension.
- Save the both HTML and
JSP file in apache tomcat web server ROOT address.
- Run the tomcat server
using command prompt.
- Open the internet
explorer. In address bar give
http://localhost:8080/ follows filename with extension to run.
- Observe the output.
HTML
AND JSP CODE:
cookie.html
<html>
<head><title>Creating
cookies</title></head>
<body
bgcolor=wheat>
<form
action=createcookie.jsp method=post>
<pre>
<center>COOKIE
MANIPULATION</center>
Enter
your Name : <input
type=text name=t1 id=t1>
Enter
your Favourite Color : <input
type=text name=t2 id=t2>
</pre>
<input
type=submit value=SEND>
<input
type=reset value=CLEAR>
</form>
</body>
</html>
createcookie.jsp
<html>
<body
bgcolor=wheat>
<%
String
name=request.getParameter("t1");
String
color=request.getParameter("t2");
Cookie
added=null;
added=new
Cookie(name,color);
response.addCookie(added);
%>
<a
href="showcookie.jsp">Show Cookies</a>
</body>
</html>
showcookie.jsp
<%
Cookie
cookies[]=request.getCookies();
for(int
i=0;i<cookies.length;i++)
{
out.print(cookies[i].getName()+"-"+cookies[i].getValue()+"<br>");
}
%>
RESULT:
Thus the JSP page for cookies manipulation
is designed, executed and the required output is obtained.
UPLOADING FILE
EX.NO : 13
DATE
:
AIM:
To write a JSP code to upload data from
client side.
HARDWARE
REQUIREMENTS:
1. Computer with Pentium
processor
SOFTWARE
REQUIREMENTS:
1. Notepad or any editor
2. Apache Tomcat Server 5.0
3. JDK 1.7
4. Internet Explorer
PROCEDURE:
1. Open the notepad or any
notepad.
2. Edit the HTML coding and
save it with .html extension.
3. Edit the JSP coding and save
it with .jsp extension.
4. Save the both HTML and JSP
file in apache tomcat web server ROOT address.
5. Run the tomcat server using
command prompt.
6. Open the internet explorer.
In address bar give
http://localhost:8080/ follows filename with extension to run.
7. Observe the output.
HTML
AND JSP CODE:
upload.html
<html>
<head>
<title>New
Page 1</title>
</head>
<body
bgcolor=olive>
<h1><center>Uploading
File....</center></h1>
<form
method="POST" action="up.jsp">
<p><input
type="file" name="filename"
size="20"></p>
<p><input
type="submit" value="Upload" name="B1">
<input
type="reset" value="Reset"
name="B2"></p>
</form>
</body></html>
up.jsp
<<%@
page import="java.util.*,java.io.*" %>
<%
String
path=request.getParameter("filename");
String
newpath="";
int
count=0;
if(path!=null)
{
ArrayList arr=new ArrayList();
StringTokenizer st=new
StringTokenizer(path,"\\");
while(st.hasMoreTokens())
{
arr.add(count,st.nextToken());
count++;
}
newpath="c:/upload/"+arr.get(count-1);
int c;
FileInputStream fis=new FileInputStream(path);
FileOutputStream fos=new FileOutputStream(newpath);
while((c=fis.read())!=-1)
{
fos.write((char)c);
}
out.print("File Uploadad from :
"+path+"<br>");
out.print("Uploaded file saved in :
"+newpath);
}
%>
RESULT:
Thus the JSP page for uploading file is
designed, executed and the required output is obtained.
IMAGE MAP
EX.NO : 14
DATE
:
AIM:
To write a JSP application using image map
to give information about the institution
HARDWARE
REQUIREMENTS:
1. Computer with Pentium
processor
SOFTWARE
REQUIREMENTS:
1. Notepad or any editor
2. Apache Tomcat Server 5.0
3. JDK 1.7
4. Internet Explorer
PROCEDURE:
1. Open the notepad or any
notepad.
2. Edit the HTML coding and
save it with .html extension.
3. Edit the JSP coding and save
it with .jsp extension.
4. Save the both HTML and JSP
file in apache tomcat web server ROOT address.
5. Run the tomcat server using
command prompt.
6. Open the internet explorer.
In address bar give
http://localhost:8080/ follows filename with extension to run.
7. Observe the output.
HTML
AND JSP CODE:
EXNO14.html
<html>
<body>
<a href="http://localhost:8084/WebApplication2/exno14.jsp">
<img name="map"
src="
" ismap>
</a>
</body>
</html>
exno14.jsp
<html>
<body>
<%
String coord = request.getQueryString();
int comma_pos = coord.indexOf(",");
int x = Integer.parseInt(coord.substring(0,
comma_pos));
int y =
Integer.parseInt(coord.substring(comma_pos+1));
if ( x > y )
out.print("The
Right region of Institute contains : ECE, EEE, ITI and Boys Hostel
Blocks");
else
out.print("The
Middle region of Institute contains : Main Block I and II, Computer and
Girls Hostel Blocks");
%>
</body>
</html>
RESULT:
Thus the JSP application for image map is
designed, executed and the required output is obtained.
HIT COUNTER
EX.NO : 15
DATE
:
AIM:
To write a JSP code to check how many users
have visited a website using application object.
HARDWARE
REQUIREMENTS:
- Computer with Pentium
processor
SOFTWARE
REQUIREMENTS:
- Notepad or any editor
- Apache Tomcat Server
5.0
- JDK 1.7
- Internet Explorer
PROCEDURE:
- Open the notepad or any
notepad.
- Edit the HTML coding
and save it with .html extension.
- Edit the JSP coding and
save it with .jsp extension.
- Save the both HTML and
JSP file in apache tomcat web server ROOT address.
- Run the tomcat server
using command prompt.
- Open the internet
explorer. In address bar give
http://localhost:8080/ follows filename with extension to run.
- Observe the output.
JSP
CODE:
visit.jsp
<html>
<body>
<%
//session object
Integer scount=(Integer)session.getAttribute("scount");
if(scount==null)
{
scount=new Integer(1);
}
else
{
scount=
new Integer(scount.intValue()+1);
}
session.setAttribute("scount",scount);
//application
object
Integer
acount=(Integer)application.getAttribute("acount");
if(acount==null)
{
acount=new Integer(1);
}
else
{
acount=
new Integer(acount.intValue()+1);
}
application
.setAttribute("acount",acount);
%>
<h1>your
session ID is <%=session.getId()%><h1><br>
<h1>
your have visited this page <%=scount%>times</h1><br>
<h1>
This page has been visited by all user
<%= acount%>times</h1><br>
</body></html>
OUTPUT:
RESULT:
Thus the JSP code Hit Counter is designed, executed and the required output
is obtained.
LOGIN PERMISSION
EX.NO : 16
DATE
:
AIM:
To write a JSP code to check whether a
person will be permitted to open a particular page or not using permission
checker component.
HARDWARE
REQUIREMENTS:
- Computer with Pentium
processor
SOFTWARE
REQUIREMENTS:
- Notepad or any editor
- Apache Tomcat Server
5.0
- JDK 1.7
- Internet Explorer
PROCEDURE:
- Open the notepad or any
notepad.
- Edit the HTML coding
and save it with .html extension.
- Edit the JSP coding and
save it with .jsp extension.
- Save the both HTML and
JSP file in apache tomcat web server ROOT address.
- Run the tomcat server using
command prompt.
- Open the internet
explorer. In address bar give
http://localhost:8080/ follows filename with extension to run.
- Observe the output.
HTML
AND JSP CODE:
login.html
<html>
<head>
<title>
Login
Page
</title>
</head>
<body>
<form
action=log.jsp method=post>
<h1><center>Login
Page</center></h1>
Username
:<input type=text name=t1 id=t1><br>
Password
:<input type=password name=t2 id=t2><br>
<input
type=submit name=b1 value=LOGIN>
<input
type=reset name=b2 value=CLEAR>
</form>
</body>
</html>
log.jsp
<html>
<head>
<title>Welcome</title>
</head>
<body>
<%
String
user=request.getParameter("t1");
String
pass=request.getParameter("t2");
if((user.equals("abc"))&&(pass.equals("computer")))
{
out.print("You are an authorized
user..!"+"<br>");
%>
<a href=sample.html>Click here to
open</a>
<%
}
else
{
out.print("You are not an authorized
user..!"+"<br>");
out.print("Go back and Retype your
username and password");
}
%>
</body>
</html>
sample.html
<html>
<head>
<title>
Login
Page
</title>
</head>
<body>
Sample Test Page …
</body>
</html>
OUTPUT:
RESULT:
Thus the Login Permission JSP code is
designed, executed and the required output is obtained.
Hello World Application using AJAX
EX.NO : 17
DATE :
AIM:
To Develop a Simple Hello
World Application using
AJAX
HARDWARE
REQUIREMENTS:
- Computer with Pentium
processor
SOFTWARE
REQUIREMENTS:
- Notepad or any editor
- Apache Tomcat Server 5.0
- JDK 1.7
- Internet Explorer
PROCEDURE:
- Open the notepad or any
notepad.
- Type Html and
Javascript code to send client request and receive response from server
- Create text file and
store it as .txt extension
- Save the both HTML and
JSP file in apache tomcat web server ROOT address
- Open the internet
explorer. In address bar give
http://localhost:8084/ follows filename with extension to run.
- Observe the output.
HTML CODE:
Ajax1.html
<html>
<head>
<title>hell world
application</title>
<script>
function f1()
{
var xmlhttp;
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","sample.txt",true);
xmlhttp.send();
}
</script>
<body>
<div
id="myDiv"><h2>Ajax Welcome Application
</h2></div>
<button
type="button" onclick="f1()">Change
Content</button>
</body>
</html>
Sample.txt
Hello, Welcome to AJAX
Output
RESULT:
Thus the Hello World Application using AJAX
is designed, executed and the required output is obtained.
Reading Server Date Time from a JSP Page using AJAX
EX.NO : 18
DATE :
AIM:
To Develop an AJAX
application to get the server date time from
a JSP page using AJAX
HARDWARE
REQUIREMENTS:
- Computer with Pentium
processor
SOFTWARE
REQUIREMENTS:
- Notepad or any editor
- Apache Tomcat Server 5.0
- JDK 1.4.0 or later
- Internet Explorer
PROCEDURE:
- Open the notepad or any
notepad.
- Type Html and
Javascript code to send client request and receive response from server
- Type JSP code and store
it as .jsp extension
- Save the both HTML and
JSP file in apache tomcat web server ROOT address
- Open the internet
explorer. In address bar give
http://localhost:8084/ follows filename with extension to run.
- Observe the output.
HTML CODE:
Ajax2.html
<html>
<head>
<title>Server Date and Time
using AJAX Functionality </title>
<script>
function f1()
{
window.setInterval("getTime()",1000);
}
function getTime()
{
var url =
"http://localhost:8084/newFolder/serverdatetime.jsp";
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("mytime").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST",url,true);
xmlhttp.send();
}
</script>
</head>
<body onload="f1()">
<b> Server Time
</b> <h3
id="mytime"/>
</body>
</html>
serverdatetime.jsp
<%@page
contentType="text/html" import="java.util.*" %>
<html>
<body>
<%
out.print(new java.util.Date());
%>
</body>
</html>
RESULT:
Thus the Server Date and Time using AJAX is
designed, executed and the required output is obtained.
Html Search Page using AJAX
EX.NO : 19
DATE :
AIM:
To Develop a Html search
Page using Ajax Functionality and a server side script that returns results
based on search criteria
HARDWARE
REQUIREMENTS:
- Computer with Pentium
processor
SOFTWARE
REQUIREMENTS:
- Notepad or any editor
- Apache Tomcat Server 5.0
- JDK 1.7
- Internet Explorer
PROCEDURE:
- Open the notepad or any
notepad.
- Type Html and
Javascript code to send client request and receive response from server
- Type JSP code and store
it as .jsp extension
- Save the both HTML and
JSP file in apache tomcat web server ROOT address
- Open the internet
explorer. In address bar give
http://localhost:8084/ follows filename with extension to run.
- Observe the output.
HTML CODE:
Ajax3.html
<html>
<head>
<title>Search Page </title>
<script>
function search()
{
var url =
"http://localhost:8084/newFolder/search.jsp";
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new
XMLHttpRequest();
}
else
{
xmlhttp=new
ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if
(xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("stxt").innerHTML=xmlhttp.responseText;
}
}
var st=document.getElementById("t1").value;
st="?"+st;
xmlhttp.open("GET",url+st,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form id=f1>
Enter Search String<input type=text id=t1
size=20>
<input type=button name=b1 value=send
onclick="search()">
</form>
<hr>
<h3 id=stxt />
</body>
</html>
search.jsp
<%@page
contentType="text/html" import="java.util.*" %>
<html>
<body>
<%
String s1,s2,s3,s4,search_def;
s1=request.getQueryString().toUpperCase();
//s1="HTML";
search_def="Web documents are
developed by HTML,Jsp is a server side scripting language,html is a client side
scripting language,java technology is completely used by jsp";
s2=search_def.toUpperCase();
ArrayList arr=new ArrayList();
StringTokenizer st=new
StringTokenizer(s2,",");
int count=0;
while(st.hasMoreTokens())
{
arr.add(count,st.nextToken());
count++;
}
int i,pos;
for(i=0;i<=count-1;i++)
{
s3=(String)arr.get(i);
pos=s3.indexOf(s1);
if(pos!=-1)
out.print(s3+"<br>");
}
%>
</body>
</html>
RESULT:
Thus the Search Page AJAX is designed,
executed and the required output is obtained
No comments:
Post a Comment