struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Lea <ja...@kumachan.net.nz>
Subject Re: [OT] Re: ajax proj
Date Mon, 02 May 2005 22:28:27 GMT
Just a quick note/question about Craig's code below:

This line

    <label>${category.label}</label>

 will output the value with not xml filtering, so some values will cause 
incorrect xml to be generated.

You should use <c:out> tag to filter the <,>,',", and & characters to 
output &lt;, &gt;, &apos;, &quot;, and &amp;

    <label><c:out value="${category.label}"/></label>

and the same for the <value> element

Craig McClanahan wrote:

>On 5/2/05, Woodchuck <woodchuck_5@yahoo.com> wrote:
>
>  
>
>>JSTL is da bomb!  :)
>>    
>>
>
>Indeed it is.  If you actually need to create XML in a response to an
>XmlHttpRequest call from an Ajax client side gadget :-), here's an
>approach using a JSP 2.0 page (in xml syntax) that uses JSTL to
>iterate over a result set, and JSP expressions to pull out the data
>(copied from the Shale Use Cases example app):
>
>--------------------
><jsp:root             version="2.0"
>                      xmlns:c="http://java.sun.com/jsp/jstl/core"
>                    xmlns:jsp="http://java.sun.com/JSP/Page">
>
>  <jsp:directive.page
>                  contentType="text/xml;charset=UTF-8"/>
>
>  <categories>
>    <c:forEach            var="category"
>                        items="${lookup$listCategories.supportedCategories}">
>      <category>
>        <label>${category.label}</label>
>        <value>${category.value}</value>
>      </category>
>    </c:forEach>
>  </categories>
>
></jsp:root>
>
>--------------------
>
>The business logic that looks up the label/value pairs for the
>response doesn't have a clue how it will actually be rendered, and
>setting up a JSP page is much easier to author than building an XML
>DOM in Java code.
>
>Craig
>
>
>  
>
>>--- Rick Reumann <struttin@reumann.net> wrote:
>>    
>>
>>>Dakota Jack wrote the following on 5/2/2005 4:01 PM:
>>>      
>>>
>>>>The other aspect that is not discussed above is the removal of the
>>>>complexity from the "page".  This is where JSP, Taglibs, etc., come
>>>>into the picture.  And, I suspect, you two are talking about a
>>>>combination of this problem (keeping the page simple) and the
>>>>        
>>>>
>>>previous
>>>      
>>>
>>>>problem (using a reasonable architecture).
>>>>        
>>>>
>>>yes. For example, take a table sort example. I like being able to use
>>>
>>>JSTL (or even a display tag if that suits you) to display the
>>>collection
>>>info into the display of the table.
>>>
>>>Doing something like this within a servlet (Action) wouldn't really
>>>be
>>>wrong, but just more difficult to maintain and more of pain to code
>>>(using StringBuffer and append bla bla).
>>>
>>>--
>>>Rick
>>>
>>>      
>>>

-- 
Jason Lea



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message