struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <craig...@apache.org>
Subject Re: Rendering Unfiltered Text
Date Mon, 03 May 2004 20:54:54 GMT
Bill Siggelkow wrote:

> This is somewhat of an HTML question so please don't slam me ...
>
> I am using <bean:write name="foo" property="bar" filter="false"/> to 
> display text containing HTML.  However, I would like to find a way to 
> prevent mangled markup when the data contains unbalanced tags.  For 
> example, if the value of bar is "Struts <b>rocks!" -- then when I 
> render this with filter="false" then the text and everything following 
> the text is in bold because the <b> tag does not have an </b> tag.  
> Does anyone know of a way of preventing this problem?  I tried 
> wrapping the text in <div> tags but still had the same problem.
>
When you say filter="false", you are taking responsibility for the 
content that actually gets rendered.  Struts doesn't know or care what 
you're emitting ... it doesn't even know whether it is HTML or not.  
Therefore, you're  probably going to have to employ some sort of 
avoidance strategy, such as parsing the snippet being provided by the 
property with some sort of HTML or XML parser, to ensure that everything 
balances.  If you're in control of how the snippet gets created, you 
might consider providing it as a DOM structure instead of a String ... 
rendering well-formed XML from such a structure is pretty easy, 
especially if you employ some of the XML tags in JSTL.

> Bill Siggelkow

Craig


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message