java - can not get values of getParameterValues in actual order how they are sent -
i sending registration form info through httppost method servlet , info getparametervalues. no problem getting data,but info in random order. want @ servlet info in order of how sent. seek solve reading in net nil can help. posting code of servlet here.
response.setcontenttype("text/html"); objectoutputstream out = new objectoutputstream(response.getoutputstream()); enumeration paramnames = request.getparameternames(); string params[] = new string[7]; int i=0; while(paramnames.hasmoreelements()) { string paramname = (string) paramnames.nextelement(); system.out.println(paramname); string[] paramvalues = request.getparametervalues(paramname); params[i] = paramvalues[0]; system.out.println(params[i]); i++; }
i output this
5_country united states of america 4_password zxcbbnm 1_lastname xyz 0_firstname abc 3_email abc@xyz.com 6_mobile 1471471471 2_username abcd
i want 0_firstname first 1_lastname 2_username that,because want insert info in database. here 0,1,2...i wrote indicate want value in order. code solve useful.
you won't parameter names in order using request.getparameternames();
.
you can either utilize
string [] parameternames = new string[]{"param1","param2","param3"}; for(string param : parameternames){ system.out.println(param); }
where parameternames
conains sequence in want parameters. can configure , read sequence config file.
or
you can utilize
request.getquerystring() querystring, while using method
or
you can utilize
request.getinputstream() querystring, while using post method , parse raw info query string.
after getting query string , can split , utilize way want.
java servlets http-post getparameter
No comments:
Post a Comment