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

  • Home
  • SEARCH
  • 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 74415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:21:17+00:00 2026-05-10T20:21:17+00:00

For a very simple ajax name lookup, I’m sending an id from the client

  • 0

For a very simple ajax name lookup, I’m sending an id from the client webpage to the server (Tomcat 5.5, Java 5), looking it up in a database and returning a string, which is assigned to a javascript variable back in the client (and then displayed).

The javascript code that receives the value is pretty standard:

//client code - javascript xmlHttp.onreadystatechange=function() {     if (xmlHttp.readyState==4) {         var result = xmlHttp.responseText;         alert(result);         ...     }     ... } 

To return the string, I originally had this in the server:

//server code - java myString = '...'; out.write(myString.getBytes('UTF-8')); 

Which worked perfectly, if unsafe. Later, I replaced it with:

import org.apache.commons.lang.StringEscapeUtils; ... myString = '...'; out.write(StringEscapeUtils.escapeJavaScript(myString).getBytes('UTF-8')); 

But while safer, the resulting string can’t be properly displayed if it contains special chars like ‘ñ’.

For instance, using:

escapeJavaScript('años').getBytes('UTF-8'); 

sends:

an\u00F1os 

to the client.

The question: is there a simple way to parse the resulting string in Javascript or is there an alternate escape function I can use in java that would prevent this issue?

  • 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. 2026-05-10T20:21:17+00:00Added an answer on May 10, 2026 at 8:21 pm

    The following works in every browser I’ve tried:

    javascript:alert('a\u00F1os'); 

    Perhaps your string is being escaped twice by mistake.

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

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer What about age[^0-9]{0,4}[0-9]+ if you want to capture the number… May 11, 2026 at 11:20 am
  • added an answer One way is to assign a unique number to each… May 11, 2026 at 11:20 am
  • added an answer Papers by Philip Wadler and Simon Peyton Jones should get… May 11, 2026 at 11:20 am

Related Questions

For a very simple ajax name lookup, I'm sending an id from the client
I want to create a very simple HTML/AJAX based GUI for a Python program.
I'm looking for a very simple tool to monitor the bandwidth of all my
I'm looking for a very simple example of active record in .NET (code samples
I'm coding a simple code editor for a very simple scripting language we use
In any language really, im looking for a simple (very simple) way to control
I have a very simple ASP.Net page that acts as a front end for
I've been working on a very simple crud generator for pylons. I came up
I'm trying to do a very simple INSERT using VB.NET. For some reason I'm
I'm working on a very simple game (essentially an ice sliding puzzle), for now

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.