This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes unable to understand paramValues implicit Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "unable to understand paramValues implicit Object" Watch "unable to understand paramValues implicit Object" New topic
Author

unable to understand paramValues implicit Object

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634


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 .


OCPJP 6.0 93%
OCPJWCD 5.0 98%
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1662
    
  25

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
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: unable to understand paramValues implicit Object