Java Servlet - get parameters with the same name
I know that I can get a parameter like:
HTML
<input type="text" name="field" value="test"> Servlet
String field = request.getParameter("field"); But what if I have multiple inputs with the same name as:
HTML
<input type="text" name="line[]" value="test1"> <input type="text" name="line[]" value="test2"> <input type="text" name="line[]" value="test3"> In PHP, I can simply use name="line[]" to get an array of all the input lines. But how to do it in java?
servlet pseudo code
String[] lines = request.getParameterArray("line"); for(String line : lines){ //do shit } To close. it
String[] lines = request.getParameterValues("line"); but the name is line , not line[]