1

I've a code block to open a given URL in default browser. I've problem opening URLs with parameters in IE, When the default browser is FireFox it works fine, but it seems that IE is removing those parameters!!! Any other way to solve this problem?

Code I am using is:

 Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler \"" + url + "\"");

I've problem with URLs like "...test.html?param1=val1&param2=val2" in IE

Thanks,

Rakesh.A

3 Answers 3

2

If using Java 1.6, try the following instead:

Desktop.getDesktop().browse(new URI(url))

This (java.awt.Desktop#browse(..)) is a platform independent way of opening the default browser.

Sign up to request clarification or add additional context in comments.

3 Comments

in fact, if you're not using 1.6, start using it. It's been out for 4 years or so. :-) oh, btw, +1
I tried to use Desktop with no success, as far as I can understand its the IE which is removing [or not accepting] parameters!
I tested it on IE7 on Windows XP!
0

You probably need to escape / encode url in some way. The & character has special meaning for the command interpreter. Or do what they other guys say and don't use rundll32 for this menial task. How did you even think to try doing it that way? It's not a good way.

1 Comment

Escaping didn't worked, I wanted to use JDK5 thats why I didn't opted for Desktop class!
0

Thanks for the suggestions, I solved it in a different way. I created a JavaScript file with the values of parameters and used it in the HTML file, might not be a clean solution, but worked for me :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.