Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing params in a hyper-link, and NOT as request parameters

 
Mallika R Kumar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have an object that I iterate over, and generate rows of hyper-links in my jsp page. The way I'm constructing the href is:
in a for loop, I have the following:
<a href="/userShow.do?userValue="+dataList.get(i)%>" > <%=dataNameList.get(i)%></a>

A user sees a list of names, and clicking on any one of them will take them to userShow.do action, where they can see its details. But, the resulting page displays the userValue in the address bar, which is a sensitive piece of information.

What is the best way to pass the value from a loop, in a href, to the next action ?

Any response will be helpful.

Thanks,
Mallika.
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you have to use hidden fields and do a post rather than a get.
 
Franck Tranchant
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

You consider "userValue" as a sensitive piece of information and you use it as hypertext link label ??

Doesn't make sense to me...

Maybe use a "userId" instead of a full name then retrieve the associated "userValue" right in the "userShow" Action.
Or use a Form submit with hidden field for each row as proposed by Steven.
Or use a frame at your application top level to 'hide' actual Actions requests from address bar.
 
Mallika R Kumar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for the responses. If I use a hidden input in the loop, then my actionform bean contains a list of values for the field, and picks the first value. This is not what I want to accomplish. How can I use post method, if I want to pass user values being generated dynamically in the loop ? If there were a submit button, and the dynamic value that needed to be passed for a field was not coming from a loop, then hidden input makes sense. But, based on the link a user clicks, I need to send that link's value. Other option is for me to have a key value mapping, for the name clicked on and its value, then populate my bean with this value, and do processing.
Will <html:link> pass values to my bean from the loop ? What is the best way to do this ?

Mallika.
 
Anil Sadi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The follwing approach may help you:

<script language="javascript">
function enableLink(userValueParamValue) {
document.linkForm.userValueParam.value=userValueParamValue;
document.linkForm.action="/userShow.do";
document.linkForm.submit();
}
</script>

<html:form action="...">
....
....
<a href="#" onCick="enableLink('<%=dataNameList.get(i)%>')"><%=dataNameList.get(i)%></a>
...
...
</html:form>

<form name="linkForm">
<input type="hidden" name="userValueParam" value=""/>
</form>

Hope it helps!!!

Anil Sadineni
 
Mallika R Kumar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks so much for your responses. Anil, the onclick event did the trick! Thanks for the code, it was very helpful.

Mallika.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic