Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to insert <br /> tags into a java String
    primarykey
    data
    text
    <p>I am trying to insert line break tags <br /> into some text and displaying it on a web page. The &lt; and > signs are being translated into <code>&amp;lt;</code> and <code>&amp;gt;</code> and the tags are showing up as text on the web page.</p> <p>The text looks like this when I select it from the database (I've output it to SYSOUT):</p> <pre><code>version 12.4 service timestamps debug datetime service timestamps log datetime service password-encryption </code></pre> <p>Then I run it through this little filter:</p> <pre><code>public DevConfigs getDevConfig() { String config = devConfig.getConfig(); Pattern pattern = Pattern.compile(".$", Pattern.MULTILINE | Pattern.DOTALL); Matcher matcher = pattern.matcher(config); String newConfig = matcher.replaceAll("&lt;br /&gt;"); devConfig.setConfig(newConfig); return this.devConfig; } </code></pre> <p>Here is the web page (it's a Seam application using facelets):</p> <pre><code>&lt;rich:tab label="Config"&gt; hello&lt;br /&gt; there&lt;br /&gt; #{devConfig.config} &lt;/rich:tab&gt; </code></pre> <p>And the page source looks like this:</p> <pre><code>hello&lt;br /&gt; there&lt;br /&gt; &amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt; version 12.&amp;lt;br /&amp;gt; service timestamps debug datetim&amp;lt;br /&amp;gt; service timestamps log datetim&amp;lt;br /&amp;gt; service password-encryptio&amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt; </code></pre> <p>As you can see, my tag comes out as HTML characters and not as tags. What do I need to do to insert line break tags at the end of each line of text??</p> <p>TDR</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload