Search code examples
javaurl-routinghttprequestatgatg-dynamo

Add/remove to parameters to request URL


I have a method

public void service(DynamoHttpServletRequest request,DynamoHttpServletResponse response){}

which gets called on request. To this request url am trying to make changes to its parameters. I can use

request.setParameter()

But I have a key with two different values. If I use request.setParameter() the second value will replace the first one as shown below.

URL-  ***"host/abc.jsp?extra=124&extra=12"***
suppose (extra,"124");
(extra,"12");

I changed the values "124" to "abc" and "12" to "cd" .. Here am not able to add the second value to the url .Upon completion of the method am getting the urls as "host/abc.jsp?extra=cd" the first value is lost. Please suggest some solution.


Solution

  • Try putting all the 'extra' values in an array and set it as the parameter:

    String[] extraArr = {"123","456"};
    request.setParameter("extra",extraArr);