struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank W. Zammetti" <>
Subject Re: ajax proj
Date Mon, 02 May 2005 19:33:12 GMT
Sure! :)

Basically view the entire server portion as one piece... at the end of
whatever it is that it does, it's returning HTML (whether it's a complete
page, as usual, or just a snippet, like with Ajax techniques usually). 
Whether that HTML is written directly to response in an Action or a JSP
processes (which is writing out to response essentially remember), it's
the same thing.

The fifth example in my webapp from the article shows this, albeit very
simplistically... the Action just constructs a string from the parameters
submitted, then shoves that string into a request attribute... the then
forwards to a JSP, which basically does nothing but outputs the string and
returns the resultant "page" (the page in this case being nothing but the

Imagine what the table sorting example would look like with this
approach... all the outputting of HTML would be removed, we would instead

request.setAttribute("sortedPresidentsList", sortedPresidentsList);

...and we'd just do a normal forward to some JSP... in the JSP we might do:

<% ArrayListhm = (ArrayList)request.getAttribute("sortedPresidentsList"); %>
<table border="1" align="center" cellpadding="2" cellspacing="0">
<th onClick="retrieveURL('');"
onMouseOut="style.background='';">First Name</th>
<th onClick="retrieveURL('');"
onMouseOut="style.background='';">Middle Name</th>
<th onClick="retrieveURL('');"
onMouseOut="style.background='';">Last Name</th>
onMouseOut="style.background='';">First Year In Office</th>
onMouseOut="style.background='';">Last Year In Office</th>
for (Iterator it = sortedPresidentsList.iterator(); it.hasNext();) {
  HashMap hm = (HashMap);

Most people would tend to do with with taglibs, but you get the picture :)

Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies

On Mon, May 2, 2005 3:20 pm, Rick Reumann said:
> Frank W. Zammetti wrote the following on 5/2/2005 2:53 PM:
>> I think most people would tell you to forward to a JSP to generate what
>> really amounts to just a snippet of HTML...
> I'm confused though, you can do that? In other words you can make an
> XMLHttpRequest from one JSP that goes to an Action and in the Action you
> can forward to another JSP to write the response and the original JSP
> that called the XMLHttpRequest somehow pulls this into the innerHTML?
> Do you have an example of this?
> I'm looking at your table sort and I don't want all the complex display
> and write out of the table to take place in a Java class. I'd like to do
> this in the JSP but not sure how that fits into the Ajax cycle.
> --
> Rick
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message