Results 1 to 9 of 9
Thread: AJAX in JSP
- 06-19-2008, 01:17 PM #1
Member
- Join Date
- Jun 2008
- Posts
- 11
- Rep Power
- 0
- 06-19-2008, 01:37 PM #2
Hi hussain,
its there in the W3schools dude.. You even have sample code in it.. refer them and post your doubts if any..
- 06-19-2008, 03:27 PM #3
Member
- Join Date
- Jun 2008
- Posts
- 11
- Rep Power
- 0
- 06-20-2008, 07:50 AM #4
Hi hussain,
use the below code and modify accordingly............
try it........Java 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>
post if you have any doubts in the above code.........
cheers..................:)
freddie
- 06-20-2008, 02:08 PM #5
Member
- Join Date
- Jun 2008
- Posts
- 11
- Rep Power
- 0
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
- 06-21-2008, 04:34 AM #6
Member
- Join Date
- Jun 2008
- Posts
- 1
- Rep Power
- 0
Hi,
You can pass data from html through hidden parameters...
From JSP to AJAX the example is already discussed above..
- 06-30-2008, 03:04 PM #7
Member
- Join Date
- Jun 2008
- Posts
- 5
- Rep Power
- 0
why not to use DWR? it can help you to use AJAX in an easy way.
- 07-01-2008, 12:13 PM #8
Member
- Join Date
- Jun 2008
- Posts
- 43
- Rep Power
- 0
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.
- 07-01-2008, 02:12 PM #9
Similar Threads
-
alternative for ajax
By site4u in forum New To JavaReplies: 6Last Post: 04-28-2011, 01:15 PM -
Jsp with Ajax
By sundarjothi in forum JavaServer Pages (JSP) and JSTLReplies: 16Last Post: 09-25-2008, 10:29 AM -
Example for Ajax-JSP
By smrithi in forum JavaServer Pages (JSP) and JSTLReplies: 8Last Post: 06-02-2008, 02:00 PM -
JAVA, Ajax, Flash
By Digital Dispatching in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 02-06-2008, 07:49 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