🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #20035

Re: HTML browser display from Java application / applet...

#20035
From: David C. Jacobson
Date: Wed, 05 Nov 1997 00:00
93 lines
3790 bytes
Nevermind.  I figured out my problem.  I had to use explicit paths and very
specific strings as a parameter to the showDocument method.  Basically, I had to
set the URL string to something like
"file:/c%7C/JBuilder/myprojects/MyProjectDeployed/SomeOtherAppletPage.html".

It works beautifully.  Thanks again for the tip.

David.

David C. Jacobson wrote:

> Kurt,
>
> Very Cool!  I wasn't familiar with the showDocument method.  Quick question:
>
> I'm not currently using an http server ... just "file://" URLs for a demo on a
> laptop.  When I use a "file://SomeOtherAppletPage.html" as the URL, I get a
> Netscape "Access Denied" error.  The SomeOtherAppletPage.html page and its
> applet are browsable and operate just fine when I launch Netscape directly to
> it.  I've tried "_top" and "_self" as parameters to showDocument with the same
> effect.
>
> Am I missing something security-wise?  (I've allready run the "Preferences
> Wrangler" against my Netscape v4.03, JDK 1.1 upgrade).
>
> Once again, thanks for the valueable pointers.  :-)
>
> David.
> Catapult Systems Corp.
> mailto:dcj@launch.com
>
> Kurt A. Zarefoss wrote:
>
> > If you want the browser to open a specific URL from an Applet, use the
> > showDocument() method of the AppletContext.  The output can go to a new
> > window, the current window, or a specific frame within the current window.
> >
> > If it is an application, then (if you don't mind trying yourself to
> > Windows), write a C/C++ function that contains a main and accepts one
> > argument (the URL to open).  The Java Application would exec this executable
> > passing in the URL as a "command line argument".  The C/C++ app would then
> > perform a ShellExecute wich will automatically launch the user's default
> > browser (whatever it is).
> >
> > Here are some Applet and C/C++ samples:
> >
> > // Applet showDocument()
> >
> >                 // Construct the URL that should be opened.  (all of these
> > steps are not necessary, I just tweaked code I had already written)
> >                 String stringURL = new String("http://www.borland.com");
> >                 URL commandURL = new URL(stringURL);
> >
> >                 // Open the URL.
> >                 AppletContext currentContext = applet.getAppletContext();
> >                 currentContext.showDocument(commandURL, "_ "); // this open
> > it in a new window.
> >
> > // C/C++ code for launching default browser
> > #include <windows.h>
> > #include <stdio.h>
> > #include <string.h>
> >
> > void main (int argc, char **argv) {
> >
> >  if ((argc != 2) || (*argv[1] == 0)) {
> >   printf ("No file passed into function.");
> >   exit (1);
> >  }
> >
> >  if ((long)ShellExecute(NULL, "open", argv[1], NULL, "", SW_NORMAL) <= 32) {
> >
> >   printf("Error: Unable to start program.");
> >   exit (1);
> >  }
> >  exit(0);
> > }
> >
> > You would call this executable like this:
> >
> >                 // Execute the command.
> >              Runtime.getRuntime().exec(command); // where command is the
> > filename.exe URL_to_open
> >
> > Good luck,
> >
> > Kurt
> >
> > --
> >
> > Kurt A. Zarefoss
> > hawk@fred.net
Technical Details
Message-ID: <346074A0.3DC58F3D@launch.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <345EDA6D.23D9C3CB@launch.com> <345F72AA.285F790F@my.signature> <34602848.6AA1D229@launch.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,b58e080f3ad2bdce
X-Google-Attributes: gidf74b3,public
From: "David C. Jacobson" <David.Jacobson@launch.com>
Subject: Re: HTML browser display from Java application / applet...
Date: 1997/11/05
Message-ID: <346074A0.3DC58F3D@launch.com>
X-Deja-AN: 287199211
References: <345EDA6D.23D9C3CB@launch.com> <345F72AA.285F790F@my.signature> <34602848.6AA1D229@launch.com>
Organization: Catapult Systems Corp.
Reply-To: David.Jacobson@launch.com
Newsgroups: borland.public.jbuilder.java.language