> If you have a signed applet, it is allowed to execute
> privileged code within itself. Ie. when the call to execute
> comes from the applet itself.
From a signed applet you can launch a new instance of the browser using
Runtime.exec. This is the most robust solution and it is quite safe from
abuse since the user only agrees to accept a digital signature from a
trusted source. We use such windows for documentation and other links for
which users click hyperlinks in applets (without destroying the applet by
launching in the same browser window).
The syntax for opening browsers is not very obvious, so here is some sample
code (where booleans such as microsoftBrowser are defined externally):
final static void showInBrowser(URL url)
{
try
{
if (microsoftBrowser && windowsOS) Runtime.getRuntime().exec("iexplore.exe
" + url);
else if (firefoxBrowser && windowsOS)
Runtime.getRuntime().exec("firefox.exe \"" + url + "\"");
else if (firefoxBrowser && macOS) Runtime.getRuntime().exec(new String[]
{"open", "-a", "Firefox.app", url.toString()});
else appletContext.showDocument(url, "_blank");
}
catch (Exception e)
{
System.out.println("Couldn't show in browser: " + e);
}
}
Nothing is done for Safari on Macintosh since showDocument still works there
(the last time I checked).
If anyone has improvements to suggest please mention them so we can all have
a robust workaround to use for signed applets.
Andrew T. - 20 Jun 2006 18:48 GMT
..
> The syntax for opening browsers is not very obvious, so here is some sample
> code (where booleans such as microsoftBrowser are defined externally):
..
> If anyone has improvements to suggest please mention them so we can all have
> a robust workaround to use for signed applets.
http://browserlaunch2.sourceforge.net/
which is software specialised to open a browser that is thoroughly
and comprehensively tested. It also tries to cover all systems.
> Nothing is done for Safari on Macintosh since showDocument still works there
> (the last time I checked).
...hmmm. 'Future proofing' might be a good idea on this
one Mickey. ;-)
Andrew T.
pcouas - 21 Jun 2006 08:18 GMT
Hi,
I want open my local document, into a left frame and not into a new
browsers
Regards
Philippe
Andrew T. - 21 Jun 2006 08:30 GMT
...
> I want open my local document, into a left frame and not into a new
> browsers
I still use frames occasionally, mostly for stuff delivered off CD,
but they are ..
- not part of the oiriginal design of HTML
- not well supported (if at all) for users of screen readers
- difficult to bookmark
..for these and many other reasons, it is a good idea to
redesign the 'application' away from using (HTML) frames.
Andrew T.
Thomas Hawtin - 21 Jun 2006 13:13 GMT
> I want open my local document, into a left frame and not into a new
> browsers
Then use the two-argument version of showDocument.
http://download.java.net/jdk6/docs/api/java/applet/AppletContext.html#showDocume
nt(java.net.URL,
java.lang.String)
Or better, don't use frames.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
pcouas - 23 Jun 2006 06:32 GMT
i have problem with showdocument and i use an signed applet
Regards
Philippe
pcouas - 23 Jun 2006 06:34 GMT
In this project ShowDocument is runing, but applet is reloaded and
showdocument launching an second time .
ShowDocument code is in init() method
Regards
Philippe
Andrew T. - 23 Jun 2006 08:29 GMT
> In this project ShowDocument is runing, but applet is reloaded and
> showdocument launching an second time .
There are a number of questions I could ask here, most of
them are answered if I can visit your applet.
(I suggest you) put an unsigned version on the web (my
browsers have no pop-up blockers), and post the URL to
the web page and code.
Andrew T.