Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
Sending array of strings from client to jersey server

How can I send an array of strings from client to jersey server? My server method looks like this:

@POST
@Produces(MediaType.APPLICATION_JSON)
public ArrayList<User> createUpdateUser(@NotNull @BeanParam User user) {
    siteDao.addUser(user);
    Collection<User> l = siteDao.listSites();
    ArrayList<User> al = new ArrayList<User>(l);
    return al;
}

User object contains the array of strings - see below.

My Java Script client method (inside my index.html) to prepare user object to be sent to server looks like this:

function getFormUserDetails() {
    var user = {
        servingDates: ['jan','feb']
    }
    return user;
}

My ajax call to the server looks like this:

$(document).ready(() => {
    $('#addUserButtonId').on('click touchstart', (event) => {
        var user = getFormUserDetails();
        $.ajax({
            url: "http://localhost:8080/remote-loader/App/User/",
            type: 'POST',
            data: user, 
            }).done((data, textStatus, xhr) => {
                // some code here
            }).fail((jqXhr, textStatus, errorThrown) => {
                console.log( errorThrown );
            }).always(() => {
            });
        });
    });

My User class looks like this:

public class User /* implements Serializable */ {
    @FormParam("servingDates") 
    private List<String> servingDates = new ArrayList<String>();
    
    public List<String> getServingDates() {
        return servingDates;
    }

    public void setServingDates(List<String> servingDates) {
        this.servingDates = servingDates;
    }
}

The problem I am facing is that user object when method createUpdateUser is called by Jersey contains an empty servingDates array.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!