Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-19-2008, 02:17 PM
Member
 
Join Date: Jun 2008
Posts: 11
haiforhussain is on a distinguished road
AJAX in JSP
How to implement AJAX in JSP ...
can anyone pls give me an example....
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-19-2008, 02:37 PM
freddieMaize's Avatar
Member
 
Join Date: Apr 2008
Posts: 62
freddieMaize is on a distinguished road
Hi hussain,
its there in the W3schools dude.. You even have sample code in it.. refer them and post your doubts if any..
__________________
"a place for everything, and everything in its place."
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-19-2008, 04:27 PM
Member
 
Join Date: Jun 2008
Posts: 11
haiforhussain is on a distinguished road
Quote:
Originally Posted by freddieMaize View Post
Hi hussain,
its there in the W3schools dude.. You even have sample code in it.. refer them and post your doubts if any..
hi
I have checked in w3schools.com ... but they given example for asp and php only ... i have searched in google also ... everywhere there is an example for asp and php only ....
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 06-20-2008, 08:50 AM
freddieMaize's Avatar
Member
 
Join Date: Apr 2008
Posts: 62
freddieMaize is on a distinguished road
Hi hussain,

use the below code and modify accordingly............

Code:
<script language="JavaScript"> function ajax() { var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { var resultTxt=xmlHttp.responseText; //resultTxt would be your result that you send from the servlet } } var any_parameter= document.formName.any_parameter.value; var url="servletName"; url=url+"?any_parameter="+any_parameter;//any_parameter- this can be a value of a textbox or something xmlHttp.open("GET",url,true); xmlHttp.send(); } </script>
try it........
post if you have any doubts in the above code.........

cheers..................
freddie
__________________
"a place for everything, and everything in its place."
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 06-20-2008, 03:08 PM
Member
 
Join Date: Jun 2008
Posts: 11
haiforhussain is on a distinguished road
hi freddie
Can u pls explain me how to pass a data from HTML page to JSP ... and how to get the data from jsp using AJAX ....

cheers
hussain
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 06-21-2008, 05:34 AM
Member
 
Join Date: Jun 2008
Posts: 1
refereence2me is on a distinguished road
Hi,

You can pass data from html through hidden parameters...

From JSP to AJAX the example is already discussed above..
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 06-30-2008, 04:04 PM
Member
 
Join Date: Jun 2008
Posts: 5
o0JSP is on a distinguished road
why not to use DWR? it can help you to use AJAX in an easy way.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 07-01-2008, 01:13 PM
pao pao is offline
Member
 
Join Date: Jun 2008
Posts: 41
pao is on a distinguished road
Quote:
Originally Posted by haiforhussain View Post
hi freddie
Can u pls explain me how to pass a data from HTML page to JSP ... and how to get the data from jsp using AJAX ....

cheers
hussain
I think Freddie gave you a pretty decent example of how to implement AJAX.... You see you need to replace the string value "servletname" with the servlet you wish to handle you request. Pass params to the servlet with the url first (its easier) capture them on the servlet with request.getParameter calls. When you have your values, do your workings and write the response back.... In that way you will have successfully passed your values back to the jsp\servlet without submitting the form and posting back to your own page.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 07-01-2008, 03:12 PM
freddieMaize's Avatar
Member
 
Join Date: Apr 2008
Posts: 62
freddieMaize is on a distinguished road
Hi hussain,
Are you still having the doubt?

And are you sure about your question. I mean
Quote:
Originally Posted by haiforhussain View Post
Can u pls explain me how to pass a data from HTML page to JSP
If that is the case then you can use hidden fields (like one of our friend mentioned).

Regards,
Freddie
__________________
"a place for everything, and everything in its place."
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Jsp with Ajax sundarjothi JavaServer Pages (JSP) and JSTL 16 09-25-2008 11:29 AM
Example for Ajax-JSP smrithi JavaServer Pages (JSP) and JSTL 8 06-02-2008 03:00 PM
alternative for ajax site4u New To Java 1 03-17-2008 01:08 PM
JAVA, Ajax, Flash Digital Dispatching JavaServer Pages (JSP) and JSTL 0 02-06-2008 08:49 AM
Ajax question Peter New To Java 1 07-09-2007 01:43 AM


All times are GMT +3. The time now is 05:52 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org