As a rule, I don't like to generate HTML in the code. Wherever possible, I prefer to keep the display stuff in the display and the logic stuff in the logic components. But there are times when this isn't practical. For example, I have an app which allows people to edit, store, and display formatted text on web pages. It uses a RichFaces HTML editor control, so the raw data is in HTML form (which is still better than hard-coding HTML in
java code).
To display that kind of stuff, you can use the <h:outputText escape="false" value="...."/> construct. If your text contains end-of-line characters, you can use a
string search-and-replace function to substitute "<br/>" tags and output the results using outputText.
Earlier versions of
JSF did not handle intermixing raw HTML and JSF tags very well. It's much better these days, but you'll still end up with tidier, more portable displays if you minimize the HTML and use the JSF equivalents.