Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open a link from Java, how to hide GET parameter

Tags:

java

web

I want to open a link from Java I tried this

public static void main(String[] args) {
       try {
         //Set your page url in this string. For eg, I m using URL for Google Search engine
         String url = "http://myurl.com?id=xx";
         java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));       
       }
       catch (java.io.IOException e) {
           System.out.println(e.getMessage());
       }
   }

It is working fine but the problem is that the query string is in that url. I don't want to pass it as a query string because it is a secret key. It should be passed as hidden to webpage request. How can I do this?

like image 483
Nighil Avatar asked Feb 21 '13 11:02

Nighil


People also ask

How do I hide GET request parameters?

You cannot hide parameters. Even if you use the post method instead of the get method to remove parameters from the url. You can still see the passed parameters in the request message.

How do I hide a variable in a URL?

If you want to hide GET variables or values you should not use GET. In GET methods the data will always be send as part of the url. If you want to 'hide' the data (or not show it in the URL) from the user you should use a POST method.


1 Answers

You can't, directly

You'd need to use a POST instead of a GET to hide the value and the URL does not encode the method used to access it, so it will always use GET.

You could conceivably write out a HTML file that automagically does a POST to the desired URL (using some JavaScript) and open that (using a file:// URL).

But note that "hiding" the parameter like this adds no real security! An interested user that wants to know the value that his PC sends to some site will be able to see it. It might take slightly more effort to find it, but it's definitely not impossible.

like image 153
Joachim Sauer Avatar answered Oct 26 '22 16:10

Joachim Sauer