How to un-escape HTML tags in JSP/Struts

Discussion in 'Java' started by John, Mar 7, 2008.

  1. John

    John Guest

    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
     
    John, Mar 7, 2008
    #1
    1. Advertising

  2. John

    Roedy Green Guest

    On Fri, 7 Mar 2008 06:10:40 -0800 (PST), John
    <> 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
     
    Roedy Green, Mar 7, 2008
    #2
    1. Advertising

  3. John

    Mark Space Guest

    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.
     
    Mark Space, Mar 8, 2008
    #3
  4. John

    Tim B Guest

    "John" <> wrote in message
    news:...
    > 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"/>
     
    Tim B, Mar 9, 2008
    #4
  5. John

    Arne Vajhøj Guest

    Tim B wrote:
    > "John" <> wrote in message
    > news:...
    >> 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
     
    Arne Vajhøj, Mar 9, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthias Nietz
    Replies:
    1
    Views:
    3,457
    VisionSet
    Nov 12, 2003
  2. A. Brinkmann
    Replies:
    2
    Views:
    1,079
    A. Brinkmann
    Apr 16, 2004
  3. Greg Smith
    Replies:
    35
    Views:
    3,186
    Alex Kay
    Oct 24, 2004
  4. slomo
    Replies:
    5
    Views:
    1,546
    Duncan Booth
    Dec 2, 2007
  5. John M
    Replies:
    1
    Views:
    751
Loading...

Share This Page