Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Applet showDocument and init Method

Thread view: 
pcouas - 09 Jun 2006 15:04 GMT
Hi,

I have implemented an UPLOAD applet that work fine, but when after
upload, my applet tried to forwad to another URL with an ShowDocument,
init Method is calling a second time, do you have an idea.
I have putting code into init Method because i need an automatic
calling .

My code
This
this.getAppletContext().showDocument("http://172.15.5.103:80/test/toto.doc","_self");

Do you have an idea
Regards
Philippe
Andrew T. - 14 Jun 2006 00:37 GMT
...
> I have implemented an UPLOAD applet that work fine, but when after
> upload, my applet tried to forwad to another URL with an ShowDocument,

showDocument was never very reliable, and is getting less
reliable by the day.

> Do you have an idea

You might launch your applet using JWS and use the WebStart method
to get a borwser window (which at least returns true/false for
success).

Alternately, you might try adding a little JS to the page to check it
changes and if not, pop-up a dialog.

Another idea is to add a question mark (?) at the end of questions.
(Which helps people understand you, and encourages them to reply).

HTH

Andrew T.
pcouas - 19 Jun 2006 10:44 GMT
Hi,

I can not use JavaWebstart and Method with JSCRIPT give me security
acces problem

Regards
Philippe
Andrew T. - 20 Jun 2006 08:40 GMT
> I can not use JavaWebstart

Why not?

>.. and Method with JSCRIPT give me security
> acces problem

In that case, it sounds like the applet needs to be signed
(I am not very familiar with Applet/JS interaction, but
have seen some cases where it required signed code.).

HTH

Andrew T.
pcouas - 20 Jun 2006 11:38 GMT
Yes i know and my applet is still signed, i don't understand why ?

Regards
Philippe
Dag Sunde - 20 Jun 2006 14:58 GMT
> Yes i know and my applet is still signed, i don't understand why ?

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.

If you call any applet-method that execute privileged code
from a JavaScript function, the security system recognize
this (Your Javascript is not signed and granted permission),
and denies the execution.

One way to walk around this <hack_warning/> is to have a thread
regularly check a flag if the priv. method is to be run.
Then from Javascript, call a method in the applet that only
sets the flag and falls out.

Signature

Dag.

Mickey Segal - 20 Jun 2006 17:19 GMT
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.