• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to hide url: in struts

 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .

 
Suraj Jadhav
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 477
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Use method="post" in your html:form tag


Regards,
Sriram.V
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 477
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amit ,
Thanks for replying.
Could you please explain with an example?
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
the link to the Struts API itself has a very good self-explanatory example.

Regds,
Amit
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic