Hi There.
I wrote a class for one of my
servlets to use that accepts a Map object, which it uses to retrieve pre-defined parameters.
I originally wrote it to accept an HttpServletRequest object and then retrieved the desired parameters using request.getParameter. I decided that I wanted to make the class a bit more reusable by changing that HttpServletRequest object to a Map object so it can be used outside of a servlet environment.
My idea was to use the request.getParameterMap() method in my servlet to pass in a map. Well, I suppose I didn't read the documentation close enough, because it turns out that the values in the Map returned by request.getParameterMap() are
String arrays, so when I cast the parameters I was retrieving out of the map to (String) it blew up.
My question is, do I have to write something to convert the request parameters to a normal map and not use getParameterMap at all, or is there an intelligent way to determine if the object I'm pulling out of the map is an array, in which case I would just grab the first value in the array?
Thanks.
Jason