This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes How to hide the parameters shown in the url while submitting a form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to hide the parameters shown in the url while submitting a form" Watch "How to hide the parameters shown in the url while submitting a form" New topic
Author

How to hide the parameters shown in the url while submitting a form

vanlalhmangaiha khiangte
Ranch Hand

Joined: Sep 11, 2006
Posts: 170
Hi all,

I have a form and have some values in the form ..



When the form is submitted in the address bar all these parameters are shown.Is there anyway to hide these parameters?

Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41017
    
  43
You should use POST instead of GET, and make those parameters hidden input fields.


Ping & DNS - my free Android networking tools app
vanlalhmangaiha khiangte
Ranch Hand

Joined: Sep 11, 2006
Posts: 170
Hi,
My form is already using POST..
I cannot hide the parameter.. I have a common js script. Lots of pages are using this common script
In that I am doing this function..
CODE]
window.location=url;

[/CODE]
where url="welcome.do?"...ETC parameters following here

Thanks,
Usman Saeed
Ranch Hand

Joined: May 21, 2008
Posts: 31
Hi,
you can use HIDDEN input tag.
e.g


Usman Saeed
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41017
    
  43
Setting window.location is different from calling form.submit(). The former will always do a GET, while the latter -which is what the code you posted is doing- will use whatever the form's action attribute is set to.

The only way to keep parameters out of the URL is to use POST. So if that's the paramount requirement, then you'll need to adapt the code that's forcing you to do a GET.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to hide the parameters shown in the url while submitting a form
 
Similar Threads
Hiding parameters from URL
setting target on a href
IE issue with setting action
Multiple form with one action
multipart/form-data inputs