Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Pass two parameters via href  RSS feed

 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm doing a search in a query, and sending the parameter via a link (href)

example:





Problem we have to send (the above example) code: 02 010 and also the code: 02 011 ... but I can only send one value

Is there any way to do this?

thanks
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what you are trying to do with ||, did you try separating params with &?

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use "&", the normal HTTP character for sending multiple request parameters?
 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

When I use this::




The link only shows the list of codes: 02010





 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find that difficult to believe.
 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He just picks up the first code.

If I put the 02 011 first, it shows the list of this code, or the opposite!

But what I need is that it displays the list with the two codes (02 010 and 02 011)....:/
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show your code. In code tags.
 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here:




Another page(file_atual.jsp)

 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you getting cod in file_atual.jsp?
 
Michael Angstadt
Ranch Hand
Posts: 278
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the HttpServletRequest.getParameterValues() method to get all the values for a particular parameter name. In EL, use the "paramValues" implicit object.
 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The correct code is being sent, because I tried using the line below:

Jsp receives the code



I think the problem is being at the time of delivery, because the link is not accepting the same line with two parameters:


 
Michael Angstadt
Ranch Hand
Posts: 278
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your link looks fine, although, it would be better practice to use the <c:url> tag:



The code that is creating the "cod" attribute is probably not getting all the values of the attribute. It's probably using the getParameter() method instead of the getParameterValues() method. (Also, note that the code sample you posted is outputting an attribute, NOT a parameter. To output a parameter in EL, you would use the "param" and "paramValues" implicit objects)
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Starting over.

If you have a link with "?cod=1234&cod=5678" they're both going to be sent, period. How, *specifically*, are you trying to read them?
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Starting over.

If you have a link with "?cod=1234&cod=5678" they're both going to be sent, period. How, *specifically*, are you trying to read them?


I believe is that what David is asking is, how is your code to get those parameters?

Like:

 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This,



 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


source complete,

..JSP that takes the values



 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As has been pointed out, since there are multiple values, you'd need to use getParameterValues.
 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. i try in my JSP that takes the values




But....is wrong :/
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is. I'm not sure what else to tell you; you don't show us how you try to *use* the variable, so...

Good luck!
 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok..this right now

code correct:



thanks..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!