• Post Reply Bookmark Topic Watch Topic
  • New Topic

Finding all parameters in the request

 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm looking for a good way to iterate through all of the key, value pairs in the request. The key/value pairs that are in the request will be dynamic, so it can be anything. I do have a factory on the other side help me out w/this data once I get it, however I need to get this list first. Has anyone done this? Not sure how to attack this... Whats the best attack??
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I'm using log4j.
Just swap out the log.debug with System.out.println if you're not.
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use request.getParameterNames(). It will return an Enumeration of Strings containing the names of all the request parameters. Then you can simply iterate through the Enumeration and get the value with request.getParameter().
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahh, Ben beat me to the answer. Oh well...
 
Sharad Agarwal
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpServletRequest.getParameterNames?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sharad Agarwal:
HttpServletRequest.getParameterNames?


http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#getParameterNames()
 
Sharad Agarwal
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I meant that as a pointer for the original poster. The answer was so obvious that I wasn't sure I understood his question properly, hence the '?' mark.

Later, I notice that you have already done his homework for him, and some
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sharad Agarwal:

Later, I notice that you have already done his homework for him, and some


It was actually lazyness on my part. The file with the method was already open on my machine. It was easier to copy/paste the code into the browser than it would have been to type "getParameterNames"..

Judging from your previous posts, I was surprised to see the question mark.
Makes sense now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!