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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:56:10+00:00 2026-05-27T03:56:10+00:00

I know there are a lot of JavaScript escaping questions, but nothing seemed to

  • 0

I know there are a lot of JavaScript escaping questions, but nothing seemed to fit my needs.

I have textarea elements being dynamically displayed on a JSP. In the case of invalid form submits, I need to repopulate these fields with the values the user entered. I am doing this like so (note: simplified version):

var textareaBox = document.getElementById("myTextArea");
if (textareaBox) {
    textareaBox.value = '${myForm.myValue}';
}

Everything works fine until the user enters a value in the box that contains special characters. I’ve tried using the escape and unescape JavaScript functions individually and combined to no avail.

Does anyone know how I can handle these special character values? Note that I obviously do not want the escaped text in the textarea as this would not look good to users.

  • 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-27T03:56:10+00:00Added an answer on May 27, 2026 at 3:56 am

    Use JSTL‘s <c:out> tag to escape it and assign it as innerHTML of the text area:

    textareaBox.innerHTML = '<c:out value="${myForm.myValue}" />';
    

    But why don’t you just display it in textarea’s body directly without the need for JS?

    <textarea id="myTextArea"><c:out value="${myForm.myValue}" /></textarea>
    

    The <c:out> (and its EL function counterpart fn:escapeXml()) escapes XML special characters.

    See also:

    • Not able to display special characters properly in a JSP page
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there a lot of similar questions to this, but I didn't find
I know there are a lot of similar questions on SF, but I think
I know there are a lot of questions around on this subject, but I've
I know there are a lot of such questions on stackoverflow but I couldn't
I know there are a lot of questions similar to mine, but I actually
I know that there are a lot of similar questions, but no one the
I know there are a few questions out there but I've tried a lot
I know there are a lot of OO javascript questions on SO and I
i know there are a lot questions like this but i really cant get
I know there is a lot on this topic but I can't get any

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.