Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put "new line" in JSP's Expression Language?

Tags:

java

jsp

jsf

el

What would be right EL expression in JSP to have a new line or HTML's <br/>? Here's my code that doesn't work and render with '\n' in text.

<af:outputText value="#{msg.TCW_SELECT_PART_ANALYSIS}\n#{msg.TCW_SELECT_PART_ANALYSIS2}"/>
like image 588
Roman Kagan Avatar asked Dec 15 '09 15:12

Roman Kagan


Video Answer


1 Answers

Since you want to output <br />, just do:

<af:outputText value="#{msg.TCW_SELECT_PART_ANALYSIS}<br />#{msg.TCW_SELECT_PART_ANALYSIS2}" escape="false" />

The attribute escape="false" is there to avoid the <br /> being HTML-escaped.

You can even display the two messages in separate tags and put the <br /> in plain text between them.

<af:outputText value="#{msg.TCW_SELECT_PART_ANALYSIS}" />
<br />
<af:outputText value="#{msg.TCW_SELECT_PART_ANALYSIS2}" />

If you're still on JSF 1.1 or older, then you need to wrap plain HTML in <f:verbatim> like:

<f:verbatim><br /></f:verbatim>
like image 135
Bozho Avatar answered Oct 20 '22 01:10

Bozho