Sihan’s Blog

Tech Talks

Posts Tagged ‘Sending Array to servlet

Sending array in GET method in Java Servlet

with 2 comments

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 namesarray will contain all the four values passed in ‘name‘ parameter.

Written by sihan

August 14, 2008 at 9:18 PM