views:

101

answers:

2

Hi,

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

+1  A: 

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.

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

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.

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