It's not a secret anymore!*
The moose likes Struts and the fly likes How to hide url: in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to hide url: in struts" Watch "How to hide url: in struts" New topic
Author

How to hide url: in struts

Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Hi ,
Im developing a web page , where upon clicking a method , the parameters are being passed through the url ,and hence my parameters, are being exposed . This query may not be specific to struts. But id like to know how I could hide my parameters .I ve placed the code of my jsp below . Please advice .



Learning and Learning!-- Java all the way!
Suraj Jadhav
Greenhorn

Joined: Mar 10, 2010
Posts: 25
There are various ways. Simple could be, to pass the parameter through request/session. Or you can implement unique token for each request so that url cannot be tempered. One third party tool is CSRF Guard. You can also use AJAX in your code to hide url. There are various ways so check which one suites for you.
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Hi Suraj,
Thanks for replying!! Could you please give me an example on how to implement it using request /session .As im relatively new to Java and am trying to learn on the job . Thank you.
sri ramvaithiyanathan
Ranch Hand

Joined: Nov 20, 2010
Posts: 109
Hi,
Use method="post" in your html:form tag


Regards,
Sriram.V


For java examples,ebooks,interview questions,visit this blog
http://periodicupdates.blogspot.com/
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

sri ramvaithiyanathan wrote:Hi,
Use method="post" in your html:form tag


Regards,
Sriram.V



Hi,
I did try out the post method as you have mentioned before too , but there was no change . I'm pasting that ;line from my code and also the url being generated upon clicking the respective button , please let me know where im going wrong.
Thanks .




Upon Submitting the form , the url generated is --

URL--http://localhost:8080/StrutsDBApp/login.do?param=addDomain

Im trying to do away with the "param=addDomain " part here ..


Any help would be appreciated.



Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Of course anything you put into the action value will be used as is. If you don't want it on the URL, then don't put it there!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Bear Bibeault wrote:Of course anything you put into the action value will be used as is. If you don't want it on the URL, then don't put it there!


Thanks for replying! Pardon my ignorance, So there is no method where i can hide the parameter that i pass through to the form ??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Make it a hidden input rather than a parameter on the action URL.

By the way, I hope you're not doing this for security reasons. POSTs are not any more secure than GETs.
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 511
Hello,
Have a look at MappingDispatchAction class.
This will help you to get rid of the parameter.

Keep in mind though as mentioned earlier if you choose to prepare URL with query string parameters then you cannot hide them. Looking at your URL I felt that you are trying to use conditions based on the parameter to decide what action to be taken. This can be best addressed using the above approach (in STRUTS).

Regds,
Amit
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Hi Amit ,
Thanks for replying.
Could you please explain with an example?
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 511
hi,
the link to the Struts API itself has a very good self-explanatory example.

Regds,
Amit
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

amit punekar wrote:Hello,
Have a look at MappingDispatchAction class.
This will help you to get rid of the parameter.

Keep in mind though as mentioned earlier if you choose to prepare URL with query string parameters then you cannot hide them. Looking at your URL I felt that you are trying to use conditions based on the parameter to decide what action to be taken. This can be best addressed using the above approach (in STRUTS).

Regds,
Amit

Hi Amit,
I did try out your method. The MappingDispatch Action is effective for passing urls , however when i call a particular method to which a parameter is being passed , the "param" is back on the querystring . It would be great if anyone could help me to get the param part out of the url . Im placing the modified struts config and action class after using Mapping Dispatch , please have a look at if I'm on the right track .
Thanks in Advance,

Struts- config



Action Class--




Thanks


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to hide url: in struts
 
Similar Threads
Help in Debugging
Struts- Error while java.lang.IllegalArgumentException: setAttribute: name parameter cannot be null.
drop down list: on refresh page by default select option is not coming
doubt regarding <html:select>
In jsp page After decimal i need only 2 values(for ex:477.74)