Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4052100
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:16:40+00:00 2026-05-20T14:16:40+00:00

I have a JSF page which is outputting XHTML (from a facelet). One of

  • 0

I have a JSF page which is outputting XHTML (from a facelet). One of the fields has user-generated HTML which is causing parsing errors in my web browser (Safari).

I understand that this is because XHTML is strict and follows the rules of XML, unlike HTML. What is the best way of embedding this HTML while avoiding fatal parsing errors?

One thing I’ve thought of is replacing all instances of say <br> with <br />, but there’s got to be a better solution than that.

Here’s another example of something I need to embed:

This is my sample text.<br>The address is Wind & Fire.

Notice here that the line break tag needs to be self-enclosing, and the ampersand should probably be &aamp;

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:16:40+00:00Added an answer on May 20, 2026 at 2:16 pm

    Use a HTML parser which returns well formed HTML syntax. I can recommend Jsoup for this.

    Kickoff example:

    String userHtml = "foo<br>bar&baz";
    String wellFormedHtml = Jsoup.parse(userHtml).body().html();
    System.out.println(wellFormedHtml); // foo<br />bar&amp;baz
    

    Just apply this once when you’re about to process submitted user input.

    Jsoup offers more advantages as well, such a Whitelist which you can use to strip out potential malicious HTML/JS code which can open XSS attack holes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSF Page which gets few inputs from the User, I want
I have a pretty complex JSF page (we use JSF2 with facelet) in which
I have a JSF page which has a variable number inputText elements containing numeric
I have an JSF page backed by NewsBean.java which has <f:event type=preRenderComponent listener=#{newsBean.init} />
I have a JSF page with a few fields. I followed this tutorial from
I have a JSF/Seam web app which has a page with a form which,
We have a rich:comboBox on a JSF page which has a valueChangeListener that calls
I have a JSF 2.0 page where the user logs in and he has
I have a JSF page that displays a RichFaces Treeview, from a TreeNodeImpl model
I have jsf application in which I have to use a facelet custom component

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.