Hi Gurus,
I develop console application that Open Web Browser and pass URL with
query string.
My code is as below:
public static void main(String[] args)
{
try
{
String command = "cmd /c start "+
"http://localhost:8084/NCC/Banking?"+
"CTRL_CODE=GetAudFile&"+
"zipcode=10001&file=A" ;
System.out.println("URL is :"+command);
Runtime.getRuntime().exec(command);
return;
}
catch (Exception e)
{
System.out.println("Error :: "+e);
}
}
When i run this code it opens the required URL but it doesn't take the
query string i.e. zipcode and file.
i.e. when debug the programmer i able to get the value for CTRL_CODE
but cann't able to get value(null) for zipcode and file in servlet.
Could anyone help me?
Thanks in Advance
Sanjeev
sanjeev.atvankar@gmail.com
Andrew Thompson - 16 Oct 2007 11:15 GMT
...
>I develop console application that Open Web Browser and pass URL with
>query string.
>My code is as below:
...
This few lines of code is a very fragile way to try and find the
default browser - there are probably better alternatives.
JWS BasicService.showDocument(URL)
Applet AppletContext.showDocument(URL)
pre 1.6 Desktop application BrowserLauncher2
1.6+ Desktop.browse(URI)
As an aside - I put the couple of lines of the URL
and params together through the JWS showDocument
method* and it retained the params. Of course it was
a 404 here - but that is not the point.
Note that web start is not suited to pure console
applications, so I expect you will be better looking
to Desktop.getDesktop().browse().
OTOH, opening a browser from within a console app.
seems a little suspicious in the first place..
Is this code expected to work in a 'headless' environment?
(Something like a server that supports *no* GUIs at all).
* <http://www.physci.org/jws/#bs>
<http://www.physci.org/jws/basicserv.jnlp>

Signature
Andrew Thompson
http://www.athompson.info/andrew/
Sabine Dinis Blochberger - 17 Oct 2007 11:29 GMT
> Hi Gurus,
>
> I develop console application that Open Web Browser and pass URL with
> query string.
I use java.awt.Desktop in my Application, it might be a more independent
approach.
private void lblURLMouseClicked(java.awt.event.MouseEvent evt) {
// open browser with url
// Before more Desktop API is used, first check
// whether the API is supported by this particular
// virtual machine (VM) on this particular host.
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(URI.create(lblURL.getText()));
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
Hope it helps any.

Signature
Sabine Dinis Blochberger
Op3racional
www.op3racional.eu