0

Is there anyway to remove the GET parameters from the request URL? Such that when the response arrives to the client, the window's location will be a URL clean from GET parameters. Is there anyway to do this without doing any redirects and that the parameters passed will be accessible on the server?

Thanks!

Purpose:
It is to shorten the URL. Currently in my site, links will have a handler that will convert GET parameters into hash parameters. After this, a location hash change listener will perform an AJAX request (with the location hash parameters) to reload certain parts of the document. When trying to open the links in new windows/tabs, I plan to "clean" the URL parameters and put it into the location hash, delimited by some string. If it is not possible to "clean" the URLs, it might become too long as there will be GET parameters and location hash parameters as well.

Ram
  • 1,016
  • 4
  • 15
  • 25
  • You cannot remove anything from URL.This is by protocol design. If you do not want the parameters to appear in query string use POST method instead of GET. – Santosh Aug 08 '13 at 05:26

3 Answers3

0

You could use a Servlet Filter with a HttpServletRequestWrapper.

In its doFilter method, you can impact on the Request.

Here is the official documentation on the Filter interface, and here is the page about HttpServletRequestWrapper.

Finally, here is an good SO page about what you want to do.

Community
  • 1
  • 1
Mena
  • 47,782
  • 11
  • 87
  • 106
0

GET parameters are URL encoded , thats the way it is defined http://www.w3schools.com/tags/ref_httpmethods.asp there are a few encoding methods that can be used ,like base64 , but it can be decoded anyways if there is some information you want to send to the server securely , u can use POST method instead , also you can map your pages in the web.xml and add a filter with authentication check if you want to avoid the user from playing around .

shubham
  • 547
  • 2
  • 6
  • 20
0

What is your intention for not having request parameters appear in the URL? If it's purely aesthetics then you could always use REST style urls - much like Stackoverflow - where the parameters are tokens within the URL.

Otherwise I don't believe it's possible for a client to request a certain URL?param1=.... and then end up with just URL without either a redirect from the server or the original request was a POST. Difference between POST and GET

ikumen
  • 11,275
  • 4
  • 41
  • 41