aspose file tools*
The moose likes Struts and the fly likes passing values from jsp to struts action without showing in address bar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "passing values from jsp to struts action without showing in address bar" Watch "passing values from jsp to struts action without showing in address bar" New topic
Author

passing values from jsp to struts action without showing in address bar

Rahul Dhamecha
Greenhorn

Joined: Mar 13, 2012
Posts: 8
Hi, I have a jsp file wherein I am iterating a list of Strings.
Each String by itself is a hyperlink which when clicked invokes a method in an action class.

I want to transfer the value of the String clicked from the jsp page to the action class without showing the value in the address bar. I am aware that using html:link enables me to transfer the parameter to the action class but it shows in the address bar.

I also tried using a scriptlet and used request.setAttribute() method to set the value of an attribute but when I retrieve the same in the action class using request.getAttribute() I encounter a NULL

How should I achieve my objective.
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Hi, Genuinely submit the form i.e. set these values in the form using onClick javascript method call which submits the values and retrieve the same in action.


Have Fun with Java
little,little.. little by little makes a lot..
Rahul Dhamecha
Greenhorn

Joined: Mar 13, 2012
Posts: 8
Shankar Tanikella wrote:Hi, Genuinely submit the form i.e. set these values in the form using onClick javascript method call which submits the values and retrieve the same in action.


These values are not to be obtained from the user. I am printing a list of items, where in each item is associated with a unique Id which is confidential. Each list is also a link in itself; so when I click on this link I am redirected to the next page depending on the confidential id I want to pass. I have used the html:link struts tag to create a link. I want to pass that confidential id upon every click.

How should I set the values in the javascript? Won't these values be treated as plain javascript variables and will not be passed on the form submit?
If possible please provide a code, I am unable to find a solution to the above
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
What do you mean by "confidential id"? From who are you trying to hide it, and why? Note that POST parameters are as much open to inspection as GET parameters, they're just not part in the URL.
Rahul Dhamecha
Greenhorn

Joined: Mar 13, 2012
Posts: 8
Tim Moores wrote:What do you mean by "confidential id"? From who are you trying to hide it, and why? Note that POST parameters are as much open to inspection as GET parameters, they're just not part in the URL.


By confidential I mean, I don't want them to be seen in the url. These values are the primary values stored in my database for each of the enlisted items.

Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
The alternative to showing them in the URL is to make them hidden fields in a POST request - that provides no confidentiality either. If you need to round-trip them to the client and back to the server (instead of storing them in a server-side session), you should encrypt those values.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: passing values from jsp to struts action without showing in address bar