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
string).

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

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">
<tr>
<th onClick="retrieveURL('example2RenderTable.do?sortField=firstName');"
onMouseOver="style.background='#c0c0c0';"
onMouseOut="style.background='';">First Name</th>
<th onClick="retrieveURL('example2RenderTable.do?sortField=middleName');"
onMouseOver="style.background='#c0c0c0';"
onMouseOut="style.background='';">Middle Name</th>
<th onClick="retrieveURL('example2RenderTable.do?sortField=lastName');"
onMouseOver="style.background='#c0c0c0';"
onMouseOut="style.background='';">Last Name</th>
<th
onClick="retrieveURL('example2RenderTable.do?sortField=firstYearInOffice');"
onMouseOver="style.background='#c0c0c0';"
onMouseOut="style.background='';">First Year In Office</th>
<th
onClick="retrieveURL('example2RenderTable.do?sortField=lastYearInOffice');"
onMouseOver="style.background='#c0c0c0';"
onMouseOut="style.background='';">Last Year In Office</th>
</tr>
<%
for (Iterator it = sortedPresidentsList.iterator(); it.hasNext();) {
  HashMap hm = (HashMap)it.next();
%>
  <tr>
  <td><%=(String)hm.get("firstName")%></td>
  <td><%=(String)hm.get("middleName")%></td>
  <td><%=(String)hm.get("lastName")%></td>
  <td><%=(String)hm.get("firstYearInOffice")%></td>
  <td><%=(String)hm.get("lastYearInOffice")%></td>
  </tr>
<%
}
%>
</table>

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

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to