• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

How to hide url: in struts

 
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.



 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Have you no shame? Have you no decency? Have you no tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic