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

Struts and AJAX

jaffrin abdul salam

Joined: Sep 16, 2005
Posts: 23
What are the disadvantages of sending all the request to struts in jsp via AJAX?
The project that i am working on is only having 6 pages and home.jsp is the main page. I want to send all the request in home.jsp via AJAX to struts to process it? Basically I will be having only one Action class for all the action in home.jsp and process those request in the execute method.
Is this way is a correct way of doing it? what are the disadvantages of doing this way?
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33124

I don't recommend using the same action for everything. If you have 6 pages, it's likely because they do 6 different things? Why not have 6 actions? This decision is independent of whether you choose to use AJAX in your application.

If you share more about what your page does, you may get more useful comments on whether or not AJAX is useful there.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
jaffrin abdul salam

Joined: Sep 16, 2005
Posts: 23
Thanks for replying. I will be having 6 different action class for the other pages.This is very simple application . As I said before , home.jsp is the main page. Users will be spending lot of time in the home page. Other pages will be preference page, Contact us etc. There will be no much action involved in other pages.
So I will be sending all the request from home page to that Struts action class for the home page.
I wanted to do same way they have done here Instead of redirecting to a jsp in the execute method I will be having like this.
// Write the HTML to response
PrintWriter out = response.getWriter();
return null; // Not forwarding to anywhere, response is fully-cooked
} // End execute()

Please advice me what is the better way.
I agree. Here's the link:
subject: Struts and AJAX
It's not a secret anymore!