Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parameters are removed when opening local URL in default browser

Tags:

java

I have the following code for opening a local web page with a parameter:

String url = "file:///C:/work/my_page.html?";
String params = "message=HelloWorld";

Desktop.getDesktop().browse(new URI(url + params));

But, when the browser is opened, the parameters string (?message=HelloWorld) is removed.

While when I call some page with http:// prefix, it does work.

How can I make it work also with local file ? (i.e. such that starts with file:///)

like image 687
SomethingSomething Avatar asked Sep 26 '22 07:09

SomethingSomething


1 Answers

You cannot. http:// is one protocol which allows parameters. file:// is another protocol which does not allow parameters.

Suggestion is - create local web site (for example jetty) and use http potocol only. BTW, all other http stuff like AJAX will not work either.

like image 99
Alex Avatar answered Oct 11 '22 12:10

Alex