• 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

Iterating Over Query Parameters

 
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I have the following request urls:

http://localhost/myApp/myAction.do?a=1&b=2&c=3
http://localhost/myApp/myAction.do?myVal=1&anotherVal=2&more=3&finally=4

In my jsp, how can I iterate over all query parameters? I'd like to do this because I'm using tiles and iframes and I need to dynamically handle the query parameters and append then to the iframe src.

Thanks in advance.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The HTTPServletRequest object has a getParameterMap method that returns a map of the parameter/value pairs. I'd suggest calling this method to get the map, and then iterating over the map to get each parameter/value pair. Example:

[ August 09, 2007: Message edited by: Merrill Higginson ]
 
Dom Lassy
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merrill. I also found out that I can use javascript to pass the query string to an iframe as well by using:



With that being said, I'll iterate over the parameterMap using the logic iterate tag to build the url. Thanks again.
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic