How to un-escape HTML tags in JSP/Struts

  • Follow


Hi,
I receive from the database HTML formatted Strings like that:

<b>Currently results</b>

Using the <bean:message> struts tag, I expect to display it on the
generated JSP page in bold. But, for some reason, the browser really
displays

<b>Currently results</b>

The source code is of course

&lt;b&gt;Current results&lt;/b&gt;

So, somewhere happens a conversion, but I do not know where; I saw,
that before calling the <bean:message> tag, the string is still with
the formatted tags, which is ok.

Can somebody tell me what am I doing wrong? Do you have some example
that works?

Thank you very much for your help,
John
0
Reply John 3/7/2008 2:10:40 PM

On Fri, 7 Mar 2008 06:10:40 -0800 (PST), John
<gundam.f0rtre55@bluebottle.com> wrote, quoted or indirectly quoted
someone who said :

>&lt;b&gt;Current results&lt;/b&gt;

To convert those entities back to text, see
http://mindprod.com/products1.html#ENTITIES

to stop Struts from quoting them in the first place, you would have to
ask someone else.
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
0
Reply Roedy 3/7/2008 11:13:28 PM


John wrote:

> The source code is of course
> 
> &lt;b&gt;Current results&lt;/b&gt;

Have you looked in the database to see what is stored there? So you are 
certain that the field contains <'s and >'s?

Show us the methods you use to retrieve this field from the database, 
and the methods you use to send it to the client. An SSCCE would be ideal.

0
Reply Mark 3/8/2008 4:17:04 AM

"John" <gundam.f0rtre55@bluebottle.com> wrote in message
news:8d6d97fe-9d5f-44f2-be9b-c79fdfed6f07@x30g2000hsd.googlegroups.com...
> Hi,
> I receive from the database HTML formatted Strings like that:
>
> <b>Currently results</b>
>
> Using the <bean:message> struts tag, I expect to display it on the
> generated JSP page in bold. But, for some reason, the browser really
> displays
>
> <b>Currently results</b>
>
> The source code is of course
>
> &lt;b&gt;Current results&lt;/b&gt;
>
> So, somewhere happens a conversion, but I do not know where; I saw,
> that before calling the <bean:message> tag, the string is still with
> the formatted tags, which is ok.
>
> Can somebody tell me what am I doing wrong? Do you have some example
> that works?
>
> Thank you very much for your help,
> John


try setting the filter attribute of the bean:message tag to false:

<bean:message key="message.with.html" filter="false"/>


0
Reply Tim 3/9/2008 7:37:45 PM

Tim B wrote:
> "John" <gundam.f0rtre55@bluebottle.com> wrote in message
> news:8d6d97fe-9d5f-44f2-be9b-c79fdfed6f07@x30g2000hsd.googlegroups.com...
>> Hi,
>> I receive from the database HTML formatted Strings like that:
>>
>> <b>Currently results</b>
>>
>> Using the <bean:message> struts tag, I expect to display it on the
>> generated JSP page in bold. But, for some reason, the browser really
>> displays
>>
>> <b>Currently results</b>
>>
>> The source code is of course
>>
>> &lt;b&gt;Current results&lt;/b&gt;
>>
>> So, somewhere happens a conversion, but I do not know where; I saw,
>> that before calling the <bean:message> tag, the string is still with
>> the formatted tags, which is ok.
> 
> try setting the filter attribute of the bean:message tag to false:
> 
> <bean:message key="message.with.html" filter="false"/>

Does bean:message have filter ?

http://struts.apache.org/1.3.8/struts-taglib/tagreference.html#struts-bean.tld
indicates not (and that it may be necesarry to switch to bean:write).

Arne
0
Reply ISO 3/9/2008 10:11:13 PM

4 Replies
461 Views

(page loaded in 0.178 seconds)

Similiar Articles:





7/23/2012 1:28:28 PM


Reply: