Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to receive data in .jsp file from servlet in AJAX?

 
isha krishnan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying display a dynamic table on the .jsp page using Ajax. But it jsp page is not retaining the data. i have tried to pass the data using get/set attribute. My question is how do we get HTML response in AJAX in form of table generated dynamically?
I have tried to fetch data as gievn in this code:
ajax code is


Thanks

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is textHint? What is being returned in the response?

Eric
 
isha krishnan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"txtHint' is the area where i want to dispaly result returned by the servlet
Complete Ajax file is



Now this code is sending particular area of problem to servlet which returns the doctors available for that area. I want to display that doctor list in formof a tableon same jsp where problem is selected, Thus how Ajax will help?
I am not well versed with XML so i wish to recieve datain form of text which will filled in table dynamicly.
How will it recieve data in "txtHint" from servlet?

Thanks..
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not canceling the action from the submit button so it will submit the page.

Either return false or use a button.

Eric
 
Austin Tashis
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even untyped buttons cause forms to submit in Firefox. Always return false.

Why are there two tags?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Austin Tashis wrote:Even untyped buttons cause forms to submit in Firefox.

There's really no such thing as an "untyped" button. If it is omitted, it defaults to "submit". This is true of most browsers, not just Firefox.

You should always explicitly type buttons.
 
isha krishnan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are no two html tags in code. its here typing mistake i made. Button is also working fine since i have tried this code to display a simple text file in defined area.

Now i am facing problem in getting data display in form of table on Same JSP page from where request goes. This is what is ajax?
Now i guess my problem is clear to you, just tell me how can i recieve data in jsp from servlet ? is there any role of ajax responseTEXT/HTML method. This is used to define the type of data we want to recieve. here data would in text form
But how to get ? Using get/set Attributes or any other way?any link will also help if you have to refer

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic