• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Finding all parameters in the request

 
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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??
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I'm using log4j.
Just swap out the log.debug with System.out.println if you're not.
 
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahh, Ben beat me to the answer. Oh well...
 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HttpServletRequest.getParameterNames?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic