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 7034103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:08:44+00:00 2026-05-28T01:08:44+00:00

I need to escape some text before displaying the contents on the webpage, and

  • 0

I need to escape some text before displaying the contents on the webpage, and this in fact is being done correctly. However when I display the String in html, the escape characters will still be displayed. The following is such an example:

hello there my ni&%ame is + - && !

and the respective string with escaping is the following:

hello there my ni&%ame is + - && !

I’ve read somewhere that the core in taglib will only escape the basic ones such as >, < , “, \t and space. however none of these escape sequences are removed from the html code. Does any of you know how to be able to solve this problem please? thanks

the following is part of the code used to convert a specific character to its escape character:

while (character != CharacterIterator.DONE ){
         if (character == '<') {
           result.append("&lt;");
         }
         else if (character == '>') {
           result.append("&gt;");
         }
         else if (character == '&') {
           result.append("&amp;");


                } .....
       return result;
}

the escaping part is done and works perfectly.. the problem occurs when i try to display the string with escaped characters onto an html page

  • 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-28T01:08:44+00:00Added an answer on May 28, 2026 at 1:08 am
    if (character == '<') {
        result.append("&lt;");
    }
    else if (character == '>') {
        result.append("&gt;");
    // ...
    

    Remove this. You don’t need it. The JSTL <c:out> already does this job.

    <c:out value="${someBean.someProperty}" />
    

    Your HTML string is otherwise escaped twice. Each & becomes an &amp; again and so on.
    If you really need to take the escaping in own hands (why?) then just don’t use <c:out> at all:

    ${someBean.someProperty}
    

    or turn off its escaping by escapeXml="false":

    <c:out value="${someBean.someProperty}" escapeXml="false" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason this isn't working - maybe I need to escape some of
I need to add some random html content with text before and after my
I need to escape some special characters from a JS string, but I can
I need some effective way to escape all special characters in string.For example, my
I need to be able to safely display user inputted text in the DOM
I have some XML files of this form: <?xml version=1.0 encoding=utf-8?> <?xml-stylesheet type=text/xsl href=biomirror.xsl?>
I need users to mark some section of text with custom tags, I can't
I'm doing: alert($(#div).text()); on something like this: <div id=div> &lt;div&gt; Some text &lt;div&gt; </div>
I need to escape just part user input for output. For example Hey a
I need an escape sequence for - or the minus sign for php. The

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.