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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:00:12+00:00 2026-05-14T23:00:12+00:00

I’d like to display some language specific characters from javascript but I can’t. My

  • 0

I’d like to display some language specific characters from javascript but I can’t.

My app is a Java webapp and the front end is jQuery. All the characters that are sended from the server – in a JSP or with AJAX – are displayed properly. When I want to display some text hardcoded in to the javascript file it’s broken.

I’m using Eclipse. In the JSP’s header I use:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

I’ve tried this (charset in the script element) too:

<script type="text/javascript" charset="utf-8"><c:import url="/JS/mainJS.js" /></script>

In my Eclipse I’ve set the project properties / text file encoding to UTF-8 AND I’ve checked the JS files’ resource properties / text file encoding that is UTF-8 too.

But when I try this:

$.test = function(){
    var s = "éééáááűűűű";
    alert(s);
}

I get:

éééáááűűűű

The strange thing is that: When I try in a separate html file (in the same project), It’s working:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
  <head>
    <title>Test</title>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

    <style type="text/css">
        body {background: #c0c0c0;}
    </style>

    <script type="text/javascript">
        $(document).ready(function(){
            var s = "éááűűúúú";
            $("#console").text(s);
            alert(s);
        })
    </script>

  </head>

  <body>
        <div id="console"></div>
  </body>
</html>

Even if I DO NOT use any content type and page encoding settings.

What is the problem? What shall I do? (I’m using Apache Tomcat integrated in Eclipse)

Thanks in advance!

  • 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-14T23:00:12+00:00Added an answer on May 14, 2026 at 11:00 pm

    The c:import uses the server platform default encoding if the encoding is absent in the response header of the request. Rather just use src attribute instead. The webbrowser is smarter in this.

    <script type="text/javascript" src="/JS/mainJS.js"></script>
    

    (if necessary remove the leading slash if you’re running on a fixed context instead of on domain root)

    If you really, really need the c:import for this (for which I honestly don’t see any advantage in this particular situation), then you need to write a Filter listening on /JS/* which sets the appropriate Content-Type header with the correct encoding on the response. This however won’t work if it concerns an external URL, it’s then the responsibility of the external server.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have some data like this: 1 2 3 4 5 9 2 6

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.