This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes how to receive data in .jsp file from servlet in AJAX? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to receive data in .jsp file from servlet in AJAX?" Watch "how to receive data in .jsp file from servlet in AJAX?" New topic
Author

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

isha krishnan
Ranch Hand

Joined: Nov 10, 2008
Posts: 50
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

Joined: Jan 10, 2002
Posts: 61447
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
What is textHint? What is being returned in the response?

Eric
isha krishnan
Ranch Hand

Joined: Nov 10, 2008
Posts: 50
"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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: May 23, 2003
Posts: 19
Even untyped buttons cause forms to submit in Firefox. Always return false.

Why are there two tags?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61447
    
  67

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

Joined: Nov 10, 2008
Posts: 50
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to receive data in .jsp file from servlet in AJAX?