How to insert <br/"> tags in java string
I am trying to insert line break tags
in some text and display it on a web page. <and> characters are converted to <and >, and tags are displayed as text on the web page.
The text looks like this when I select it from the database (I output it to SYSOUT):
version 12.4
service timestamps debug datetime
service timestamps log datetime
service password-encryption
Then I run it through this little filter:
public DevConfigs getDevConfig() {
String config = devConfig.getConfig();
Pattern pattern = Pattern.compile(".$", Pattern.MULTILINE | Pattern.DOTALL);
Matcher matcher = pattern.matcher(config);
String newConfig = matcher.replaceAll("<br />");
devConfig.setConfig(newConfig);
return this.devConfig;
}
Here is the webpage (this is a Seam application using facelets):
<rich:tab label="Config">
hello<br />
there<br />
#{devConfig.config}
</rich:tab>
And the source of the page is as follows:
hello<br />
there<br />
<br />
<br />
version 12.<br />
service timestamps debug datetim<br />
service timestamps log datetim<br />
service password-encryptio<br />
<br />
As you can see, my tag is displayed as HTML characters, not as tags. What do I need to do to insert line break tags at the end of each line of text?
Tdr
+3
4