permaculture playing cards
The moose likes HTML, CSS and JavaScript and the fly likes Ajax - Struts - JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Ajax - Struts - JSP" Watch "Ajax - Struts - JSP" New topic

Ajax - Struts - JSP

Seby Pappachan

Joined: Nov 02, 2008
Posts: 12

I have a JSP page, in which there is a link. When i click on the link, it will execute an ajax script and in turn the script will pass the request to a struts action class. The action class will perform some DB queries.

My question is that,

Can the action class have ArrayList as the return type?

I do not want to create a html (db result may vary in size from 10 rows to 100+ rows) in the action class and pass it as a string to the caller. I want to use the iterator in JSP page.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63868

You seem to have some misconceptions.

Once a JSP is sent to the browser, it is no longer a JSP -- it's a simple HTML page like any other. So there is no way for an Ajax request (or anything else) to return a Java construct that the JSP page can operate upon.

An Ajax request returns a response like any other request. It can be an XML document, an HTML fragment, a JSON construct, or any other text value. But it is a text value.

If you need to return a list of values, you could do so in XML or JSON, and have JavaScript deal with the list, but there's no way for JSP on the page to get "re-activated".

[Asking smart questions] [About Bear] [Books by Bear]
Seby Pappachan

Joined: Nov 02, 2008
Posts: 12

Thanks for the help!
It is sorta covered in the JavaRanch Style Guide.
subject: Ajax - Struts - JSP
It's not a secret anymore!