0

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.

Charles
  • 50,943
  • 13
  • 104
  • 142
knix2
  • 327
  • 1
  • 5
  • 19
  • 1
    In general servlet request parameters will be stored as map of key/value and you can't store two keys with same name. I don't think it is possible to have same name keys in url. – kosa Jul 10 '12 at 15:12
  • Nope it works.. If you give multiple values for same key, It takes the values as string[] type.. check this..Its related to atg.. http://docs.oracle.com/cd/E26180_01/Platform.94/apidoc/atg/servlet/MutableHttpServletRequest.html#getParameterMap() – knix2 Jul 11 '12 at 15:43
  • If you use this request.getParameterMap() ..you get ..type pairs.. – knix2 Jul 11 '12 at 15:44
  • it seems atg specific feature. I need to check how it works in HttpServlet. I don't know much about atg. – kosa Jul 11 '12 at 15:45
  • It is same for both..reference-->http://docs.oracle.com/javaee/5/api/javax/servlet/ServletRequest.html – knix2 Jul 11 '12 at 15:48
  • :Got it. Thanks for the link. – kosa Jul 11 '12 at 15:51

1 Answers1

3

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

String[] extraArr = {"123","456"};
request.setParameter("extra",extraArr);
Tomer
  • 17,787
  • 15
  • 78
  • 137