1

I am creating a form using multiple inputs and submit by using jquery serialization method. When I submit form, the serialized form data is sent to server. The server receive using getter and setter but it does not work. I didn't receive any data from getter and setter. All variables is null and when I use the following code, I received the required String array.

HttpServletRequest req = ServletActionContext.getRequest();
req.getParameterMap().get("areacode[]");// this data is sent by jquery serialization method
req.getParameterMap().get("phonenumber[]");

and when I use the url like :

http://localhost:8080/PrivateSchool/saveStudent?studentname=John&clsid=1&city=NewYork&street=Street&homeno=45&username=john&password=john&role=student&areacode=89&phonenumber=122121212&areacode=90&phonenumber=789797878

it can receive by using getter and setter:

public String[] getAreacode() {
    return areacode;
}

public void setAreacode(String[] areacode) {
    this.areacode = areacode;
}

public String[] getPhonenumber() {
    return phonenumber;
}

public void setPhonenumber(String[] phonenumber) {
    this.phonenumber = phonenumber;
}

I just like using getter and setter, don't like getting from servlet request using getParameterMap() method. How could I do that? Why sent parameter's key is like areacode[] instead of areacode. pls!

3
  • and when I use the url like - this is a GET, but your form is using a POST - Debug and see what you are getting Commented Aug 24, 2016 at 1:38
  • Thanks for your reply. I used debug and I got that in parameterMap {studentname=[Ljava.lang.String;@1d76657b, username=[Ljava.lang.String;@2531c8cc, password=[Ljava.lang.String;@5e666a59, city=[Ljava.lang.String;@5bfb21f6, street=[Ljava.lang.String;@7508da4f, homeno=[Ljava.lang.String;@5ed40b8a, areacode[]=[Ljava.lang.String;@338d86ab, phonenumber[]=[Ljava.lang.String;@317bf5bd, clsid=[Ljava.lang.String;@2929b7f} key is areacode[] and I have no idea why could not receive using getter and setter. Commented Aug 24, 2016 at 2:48
  • 2
    so use String [] userName = request.getParameterValues("username"); Commented Aug 24, 2016 at 2:56

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.