aspose file tools
The moose likes JSP and the fly likes Pass two parameters via href Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Pass two parameters via href" Watch "Pass two parameters via href" New topic
Author

Pass two parameters via href

fabio alonso
Ranch Hand

Joined: May 15, 2010
Posts: 48
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

Joined: Oct 10, 2000
Posts: 1348
Not sure what you are trying to do with ||, did you try separating params with &?

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Use "&", the normal HTTP character for sending multiple request parameters?
fabio alonso
Ranch Hand

Joined: May 15, 2010
Posts: 48

When I use this::




The link only shows the list of codes: 02010





David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I find that difficult to believe.
fabio alonso
Ranch Hand

Joined: May 15, 2010
Posts: 48
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

Joined: Oct 10, 2000
Posts: 1348
Show your code. In code tags.
fabio alonso
Ranch Hand

Joined: May 15, 2010
Posts: 48
Here:




Another page(file_atual.jsp)

Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1348
How are you getting cod in file_atual.jsp?
Michael Angstadt
Ranch Hand

Joined: Jun 17, 2009
Posts: 272

Use the HttpServletRequest.getParameterValues() method to get all the values for a particular parameter name. In EL, use the "paramValues" implicit object.


SCJP 6 || SCWCD 5
fabio alonso
Ranch Hand

Joined: May 15, 2010
Posts: 48

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

Joined: Jun 17, 2009
Posts: 272

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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jul 14, 2010
Posts: 754

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:



[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
fabio alonso
Ranch Hand

Joined: May 15, 2010
Posts: 48
This,



fabio alonso
Ranch Hand

Joined: May 15, 2010
Posts: 48


source complete,

..JSP that takes the values



David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

As has been pointed out, since there are multiple values, you'd need to use getParameterValues.
fabio alonso
Ranch Hand

Joined: May 15, 2010
Posts: 48
. i try in my JSP that takes the values




But....is wrong :/
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: May 15, 2010
Posts: 48
ok..this right now

code correct:



thanks..
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Pass two parameters via href
 
Similar Threads
Struts display:column when/otherwise
Boolean Object in JSTL
JSTL how to use ELSE in JSP
Retrive variable from JavaScript to JSP page
I can pass a value from a jsp to a class ?