Results 1 to 9 of 9
Thread: Example for Ajax-JSP
- 01-22-2008, 09:50 AM #1
Member
- Join Date
- Jan 2008
- Posts
- 3
- Rep Power
- 0
Example for Ajax-JSP
Anyone knows as to how to use Ajax with JSP. I have found out that we can use JSP tags for using Ajax with JSP. I got an example for using Ajax with Jsp at Learn AJAX but here, they have not used JSP tags. The example works. But I want to know how to use JSP tags.
- 01-22-2008, 10:24 AM #2
Member
- Join Date
- Dec 2007
- Posts
- 28
- Rep Power
- 0
which jsp tag u want to use
- 01-22-2008, 10:39 AM #3
Member
- Join Date
- Jan 2008
- Posts
- 3
- Rep Power
- 0
I am a newbie to JSP tags. Want to actually know how to use them and where to start off to use them to get Ajax thing in my jsp pages
- 01-23-2008, 06:20 AM #4
Member
- Join Date
- Dec 2007
- Posts
- 28
- Rep Power
- 0
Hi,
this is a small application in ajax which i made few months back.Hope it will help u
caller.jsp :
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
">
<html>
<head>
<script src="ajax.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page using AJAX</title>
</head>
<body>
<a onclick="sendRequest('GET','index.jsp')" href="#">Server Date Time:</a>
<div id="ajax_res">Server Date Time will replace this text.</div>
</body>
</html>
index.jsp
<html>
<body>
<%=new java.util.Date()%>
</body>
</html>
ajax.js
function createRequestObject(){
var req;
if(window.XMLHttpRequest){
//For Firefox, Safari, Opera
req = new XMLHttpRequest();
}
else if(window.ActiveXObject){
//For IE 5+
req = new ActiveXObject("Microsoft.XMLHTTP");
}
else{
//Error for an old browser
alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
}
return req;
}
//Make the XMLHttpRequest Object
var http = createRequestObject();
function sendRequest(method, url){
if(method == 'get' || method == 'GET'){
http.open(method,url);
http.onreadystatechange = handleResponse;
http.send(null);
}
}
function handleResponse(){
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
if(response){
document.getElementById("ajax_res").innerHTML = response;
}
}
}
run this application may be u get some clue
- 01-23-2008, 06:29 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
A good start pal. And it is better if you can [CODE] tags when you posting next time.
- 01-23-2008, 07:35 AM #6
Member
- Join Date
- Jan 2008
- Posts
- 3
- Rep Power
- 0
I wanted to use JSP tags to build Ajax web site. But in the example you gave, you dint specify about any tag usage.. There are jsp tags which are used when we use ajax in jsp.
Thanks for ur example
- 01-23-2008, 08:07 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
It's better to find the tags usages by yourself pal :p
- 06-02-2008, 01:58 PM #8
Member
- Join Date
- Jun 2008
- Posts
- 15
- Rep Power
- 0
smrithi
Member OK FRIEND DO NOT WORRY.YOU REFER HEAD FIRST JAVA BOOK FOR JSP TAGS AND JSTL.BYEEEEEE.
- 06-02-2008, 02:00 PM #9
Member
- Join Date
- Jun 2008
- Posts
- 15
- Rep Power
- 0
Similar Threads
-
alternative for ajax
By site4u in forum New To JavaReplies: 6Last Post: 04-28-2011, 01:15 PM -
JAVA, Ajax, Flash
By Digital Dispatching in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 02-06-2008, 07:49 AM -
how to contact servlet from clientside through ajax
By santhoskumara in forum Advanced JavaReplies: 2Last Post: 08-10-2007, 06:56 AM -
Ajax question
By Peter in forum New To JavaReplies: 1Last Post: 07-09-2007, 12:43 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks