• 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

unable to understand paramValues implicit Object

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

index.jsp



param.jsp contains

code from
jstl 1.0 specification




Here ,paramValues is map that contains multiple key value pair.

then,first time the loop executes aParam.key gives key of first element of Map
1.why is foreach required ?
2.can we have the following code instead of the above one ?



i got the following output .


languages:
[Ljava.lang.String;@1124746:
lastName:
[Ljava.lang.String;@105691e:
firstName:
[Ljava.lang.String;@383118:

I am unable to get how paramValues stores the request parameters .
I thought aParam.Key would give the Key and aParam.value would give the value .
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, no. Since a request can include more than one parameter with the same name, the request contains an array of strings for the value of each parameter. That's what you are seeing in that debugging output.
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Paul is saying is correct and I just want to add some explanation.

  • paramValues is a Map of all ServletRequest parameter names and all values, like you get when you do this String[] values = request.getParameterValues(String paramName), so for every paramName there is a String[] containing the values
  • If you have a querystring like this: URL?myParam="first"&myParam="second" you can get to the individual entries like this:

  • ${paramValues.myParam[0]} -> first
    ${paramValues.myParam[1]} -> second

    Regards,
    Frits
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic