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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:43:28+00:00 2026-06-02T02:43:28+00:00

I want to send data to a java servlet for processing. The data will

  • 0

I want to send data to a java servlet for processing. The data will have a variable length and be in key/value pairs:

{ A1984 : 1, A9873 : 5, A1674 : 2, A8724 : 1, A3574 : 3, A1165 : 5 }

The data doesn’t need to be formated this way, it is just how I have it now.

var saveData = $.ajax({
      type: "POST",
      url: "someaction.do?action=saveData",
      data: myDataVar.toString(),
      dataType: "text",
      success: function(resultData){
          alert("Save Complete");
      }
});
saveData.error(function() { alert("Something went wrong"); });

The $.ajax() function works fine as I do get an alert for “Save Complete”. My dilemna is on the servlet. How do I retrieve the data? I tried to use a HashMap like this…

HashMap hm = new HashMap();
hm.putAll(request.getParameterMap());

…but hm turns out to be null which I am guessing means the .getParameterMap() isn’t finding the key/value pairs. Where am I going wrong or what am I missing?

  • 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-06-02T02:43:29+00:00Added an answer on June 2, 2026 at 2:43 am

    You don’t want a string, you really want a JS map of key value pairs. E.g., change:

     data: myDataVar.toString(),
    

    with:

    var myKeyVals = { A1984 : 1, A9873 : 5, A1674 : 2, A8724 : 1, A3574 : 3, A1165 : 5 }
    
    
    
    var saveData = $.ajax({
          type: 'POST',
          url: "someaction.do?action=saveData",
          data: myKeyVals,
          dataType: "text",
          success: function(resultData) { alert("Save Complete") }
    });
    saveData.error(function() { alert("Something went wrong"); });
    

    jQuery understands key value pairs like that, it does NOT understand a big string. It passes it simply as a string.

    UPDATE: Code fixed.

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

Sidebar

Related Questions

I want to send data that is in a java script variable to the
I have a distributed java application and I want to send the database data
Hi I want to send data to the server and then have the php
I created the list that have device detected, and I want to send data
I want to send the form data to server-side. I have two ways: Normal
I have some large chunk of data that I want to send to the
I want to make a thread in red5 application? this thread will send data
I have a webservice (ie. servlet) implemented in Java. It gets some data from
In Java, if I want to send data to form on the server, where
I want to know if an applet made in java, can send data to

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.