6

In servlet I get POST parameters where keys are not unique. Like this

id = 12, id = 13, id = 14 

So I can't use getParameterMap() to get this parameters (because HashMap contain only unique keys). What is the best way to solve this problem and get values from all non-unique parameters from POST query?

Thanks!

UPD. I cant edit request parameters (I retrieve this parameters from other app)

1 Answer 1

9

The method getParameterValues() is especially usefull when there are multiple parameters with the same name in a request. The getParameterValues() method returns the value or values of the parameter paramName. The values are returned in the form of an array of strings. If the parameter paramName has mulitple values in the request, then each of those values is returned in the array.

public abstract interface ServletRequest
{
    public abstract String[] getParameterValues(String paramString);
....

}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.