File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Ajax with java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Ajax with java" Watch "Ajax with java" New topic

Ajax with java

Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
I am using ajax with servlets. So for every different ajax call, i am calling a different servlet, getting the data through a simple Dao class and sending back as the response to html , something like this
Servlet class

So, can i directly call my simple java class (Dao) from html for ajax calls, (instead of calling it indirectly through servlet)? If yes, how can i send it back as a response (from simple java class) to ajax code(html)?

Saikat Mukherjee

Joined: Mar 06, 2008
Posts: 13
Even with ajax , the entire thing boils down to HttpServletRequest and HttpServletResponse.
There is no obvious way to do what you are asking for; afterall both the request and response objects will be handled by the container only.
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
Thanks for your reply Saikat Mukherjee.

That means, that if my form has various textfields with different ajax calls, then, i will have to go for that many servlets?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63839

Or possibly institute a front controller.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Ajax with java
It's not a secret anymore!