Posts Tagged ‘J2ee’
Sending array in GET method in Java Servlet
Suppose I want to send an array of names from any http client in get method to a servlet like,
name[0] = “sihan”
name[1] = “rasel”
name[2] = “siam”
name[3] = “shamim”
All I have to do build the query string like this :
http://server_url:server_port/servletname?name=sihan&name=rasel&name=siam&name=shamim
And in the servlet we can get the array like this:
String[] names = request.getParameterValues("name");
Then ‘names‘ array will contain all the four values passed in ‘name‘ parameter.