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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:08:52+00:00 2026-05-23T10:08:52+00:00

I am facing an issue while sending special characters in ajax POST request, these

  • 0

I am facing an issue while sending special characters in ajax POST request, these special characters are not received properly by my servlet where the request is sent.
Javascript code:

myAjaxPostrequest=new GetXmlHttpObject();
var parameters1="content="+mainContent;
    myAjaxPostrequest.open("POST", "controller", true);
    myAjaxPostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    myAjaxPostrequest.send(parameters1);

Servlet code:

String lsContentToSave = aoReq.getParameter("content");
System.out.println(lsContentToSave);

aoReq is HttpServletRequest object.

For eg. if the special character is » it prints »

I have also tried jquery post and still facing the same issue. Please let me know the fix for this.

  • 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-23T10:08:53+00:00Added an answer on May 23, 2026 at 10:08 am

    You tagged jquery-ajax, but the JS code in your question isn’t recognizeable as jQuery. Are you really using jQuery? That look more like a ripoff of the poor w3schools tutorial.

    In any way, you need to take the character encoding into account in 2 places. In the client side, when you form-encode the parameter, you should be using encodeURIComponent(). This will apply percent encoding using UTF-8.

    var parameters = "content=" + encodeURIComponent(mainContent);
    // ...
    

    In the server side, before you get any parameter from the request body, you should set the request encoding to UTF-8 as follows:

    request.setCharacterEncoding("UTF-8");
    // ...
    
    String content = request.getParameter("content");
    // ...
    

    That said, if you were really using jQuery, then you don’t need to worry about using encodeURIComponent() in the client side. jQuery will handle it all for you if you’re using $.post() function with a data object.

    $.post('controller', { 'content': mainContent}, function() {
        // Callback function here.
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are facing a strange issue while sending email. It seems that the new
I am using Appweb server (mini http server) and facing an issue while opening
I am facing an issue while streaming PDF file on a Java EE web
I am facing an issue regarding EF code first version while mapping one entity
I am facing a class resolution issue while trying to make my architecture flexible.
I'm facing an issue with RestTemplate in Spring 3.0. When I'm trying to request
I am facing an issue while executing queries.I use the same resultSet and statement
I am facing an issue while trying to use the spring android framework. I
I am working on Wi-Engine and currently facing the issue while loading two sheets
More precisely, I am facing this issue while trying to install https://github.com/barraponto/thacker-profile (commit 75c693581796eddae5fc39870dfcc2647e00c81b

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.