applet showDocument work with file protocol?

Discussion in 'Java' started by BW, Apr 8, 2004.

  1. BW

    BW Guest

    I have a signed applet with full permission. But the applet
    showDocument method seems not work with file protocol. It works fine
    with http protocol. I will really appreciate it if anyone know how
    to make it work.

    The below is the code snippet:

    ...
    try
    {
    //test file protocol
    applet.getAppletContext().showDocument(new URL
    ("file:///c:/test.txt"),"_blank");
    //test http protocol
    applet.getAppletContext().showDocument(new
    URL("http://google.com"),"_blank");
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    ....
     
    BW, Apr 8, 2004
    #1
    1. Advertising

  2. BW

    Mickey Segal Guest

    "BW" <> wrote in message
    news:...
    > I have a signed applet with full permission. But the applet
    > showDocument method seems not work with file protocol.
    > ..
    > applet.getAppletContext().showDocument(new URL
    > ("file:///c:/test.txt"),"_blank");


    The format depends on that used by the operating system. You can get the
    format from getCodeBase() if you are running the applet on the local
    computer.
     
    Mickey Segal, Apr 8, 2004
    #2
    1. Advertising

  3. BW

    BW Guest

    Thanks for answering my question. I think the format is good,
    otherwise there will be an exception thrown. I paste this to a
    browser address, it works for both IE and Netscape. (In IE, if I
    change the browser options/security/local intranet/sites, then it
    works), The only thing I am worried is that the applet showDocument
    does not support file protocol.

    "Mickey Segal" <> wrote in message news:<4075728b$0$1663$>...
    > "BW" <> wrote in message
    > news:...
    > > I have a signed applet with full permission. But the applet
    > > showDocument method seems not work with file protocol.
    > > ..
    > > applet.getAppletContext().showDocument(new URL
    > > ("file:///c:/test.txt"),"_blank");

    >
    > The format depends on that used by the operating system. You can get the
    > format from getCodeBase() if you are running the applet on the local
    > computer.
     
    BW, Apr 9, 2004
    #3
  4. BW

    Mickey Segal Guest

    "BW" <> wrote in message
    news:...
    > Thanks for answering my question. I think the format is good,
    > otherwise there will be an exception thrown. I paste this to a
    > browser address, it works for both IE and Netscape. (In IE, if I
    > change the browser options/security/local intranet/sites, then it
    > works), The only thing I am worried is that the applet showDocument
    > does not support file protocol.


    showDocument does support file protocol - we use it for local files on both
    Windows and Macintosh. On Windows XP, the new browser windows show as the
    address file designations of the form:
    file:///C:/Documents%20and%20Settings/....
     
    Mickey Segal, Apr 9, 2004
    #4
  5. BW <> wrote:
    > I have a signed applet with full permission. But the applet
    > showDocument method seems not work with file protocol. It works fine
    > with http protocol. I will really appreciate it if anyone know how
    > to make it work.



    What does "not work" mean?

    Try new File("...").toURL()



    Christian
     
    Christian Kaufhold, Apr 9, 2004
    #5
  6. BW

    BW Guest

    It works in our internal intranet in IE(win2k OS) too. For example,
    if my machine name is testComputer, then I access a html file(include
    the applet) in the web server in this machine by
    http://testComputer/html/viewFile.html. The applet inside this html
    works fine to view the local files. But if I want to access this page
    from outside of the intranet by using its full domain name, then
    nothing happens, not even an exception is thrown. For example
    http://testComputer.fulldomain.com/html/viewFile.html. Have you tried
    to access the page using the full domain name from outside of your
    company? If yes, can you let know how you manage to do it? Thanks a
    lot!

    "Mickey Segal" <> wrote in message news:<4076b90a$0$1649$>...

    > showDocument does support file protocol - we use it for local files on both
    > Windows and Macintosh. On Windows XP, the new browser windows show as the
    > address file designations of the form:
    > file:///C:/Documents%20and%20Settings/....
     
    BW, Apr 9, 2004
    #6
  7. BW

    Mickey Segal Guest

    "BW" <> wrote in message
    news:...
    > It works in our internal intranet in IE(win2k OS) too. For example,
    > if my machine name is testComputer, then I access a html file(include
    > the applet) in the web server in this machine by
    > http://testComputer/html/viewFile.html. The applet inside this html
    > works fine to view the local files. But if I want to access this page
    > from outside of the intranet by using its full domain name, then
    > nothing happens, not even an exception is thrown. For example
    > http://testComputer.fulldomain.com/html/viewFile.html. Have you tried
    > to access the page using the full domain name from outside of your
    > company? If yes, can you let know how you manage to do it? Thanks a
    > lot!


    All I have ever tried was:
    1. Opening HTML pages on the open web with
    www.SomeDomain.com/someFolder/file.html format.
    2. Opening HTML files on my own computer (Macintosh OS 9, OS X or Windows).
     
    Mickey Segal, Apr 9, 2004
    #7
  8. BW

    BW Guest

    In the applet do you open local file by
    applet.getAppletContext().showDocument(new URL
    ("file:///c:/somefile.txt"),"_blank");

    Does this working both IE and netscape? Then why mine does not work?
    Can you provide a code snippet?

    Thanks!

    "Mickey Segal" <> wrote in message news:<407711c1$0$1651$>...
    > All I have ever tried was:
    > 1. Opening HTML pages on the open web with
    > www.SomeDomain.com/someFolder/file.html format.
    > 2. Opening HTML files on my own computer (Macintosh OS 9, OS X or Windows).
     
    BW, Apr 12, 2004
    #8
  9. BW

    BW Guest

    "Not work" means nothing happens, while it suppose have a new browser
    openned to show the contents of the file. I try the file.toURL()
    method, it does not work in IE (using ms jvm, only support jdk 1.18)
    or netscape (j2sdk 1.4.1). Does this work for you? Thanks for taking
    time to answer my question!

    (Christian Kaufhold) wrote in message news:<>...
    > BW <> wrote:
    > > I have a signed applet with full permission. But the applet
    > > showDocument method seems not work with file protocol. It works fine
    > > with http protocol. I will really appreciate it if anyone know how
    > > to make it work.

    >
    >
    > What does "not work" mean?
    >
    > Try new File("...").toURL()
    >
    >
    >
    > Christian
     
    BW, Apr 12, 2004
    #9
  10. BW

    Mickey Segal Guest

    "BW" <> wrote in message
    news:...
    > In the applet do you open local file by
    > applet.getAppletContext().showDocument(new URL
    > ("file:///c:/somefile.txt"),"_blank");
    >
    > Does this working both IE and netscape? Then why mine does not work?
    > Can you provide a code snippet?


    This is the essence of the code:

    URL resourceRoot;
    boolean runningFromWeb = getCodeBase().toString().startsWith("http");
    if (!runningFromWeb) resourceRoot = getCodeBase();
    else resourceRoot = new URL("http://SomeDomain.com/);
    getAppletContext().showDocument(new URL(resourceRoot,
    "SomeFolder/SomeFilePrefix.html"), "_blank");
     
    Mickey Segal, Apr 12, 2004
    #10
  11. BW

    BW Guest

    Your code makes sense. But if you look at the begining of my
    question, it's about file protocol not http protocol, for example if
    this code works for you then it will solve my problem,
    "getAppletContext().showDocument(new URL("c:///test.txt"));"? Thanks!

    "Mickey Segal" <> wrote in message news:<407aef52$0$27671$>...

    > This is the essence of the code:
    >
    > URL resourceRoot;
    > boolean runningFromWeb = getCodeBase().toString().startsWith("http");
    > if (!runningFromWeb) resourceRoot = getCodeBase();
    > else resourceRoot = new URL("http://SomeDomain.com/);
    > getAppletContext().showDocument(new URL(resourceRoot,
    > "SomeFolder/SomeFilePrefix.html"), "_blank");
     
    BW, Apr 13, 2004
    #11
  12. BW

    Mickey Segal Guest

    "BW" <> wrote in message
    news:...
    > Your code makes sense. But if you look at the begining of my
    > question, it's about file protocol not http protocol


    If the applet is running from a local file, getCodeBase() gives you a
    reference to a file.
     
    Mickey Segal, Apr 13, 2004
    #12
  13. BW

    BW Guest

    I see. But mine is a little different. Yours is show the local file
    from local html file. Mine is show the local file from the html send
    from server, in my case, the code base will always return
    http://server.domain.com/some directory.
    So this will not work me. Thanks!

    "Mickey Segal" <> wrote in message news:<407bf58d$0$2766$>...
    > If the applet is running from a local file, getCodeBase() gives you a
    > reference to a file.
     
    BW, Apr 14, 2004
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Thompson

    Applet 'showDocument' tester

    Andrew Thompson, Sep 6, 2004, in forum: Java
    Replies:
    17
    Views:
    976
    Andrew Thompson
    Sep 9, 2004
  2. migut
    Replies:
    3
    Views:
    838
    Roedy Green
    Oct 17, 2005
  3. pcouas
    Replies:
    0
    Views:
    572
    pcouas
    Jun 9, 2006
  4. pcouas
    Replies:
    0
    Views:
    371
    pcouas
    Jun 9, 2006
  5. pcouas
    Replies:
    0
    Views:
    381
    pcouas
    Jun 9, 2006
Loading...

Share This Page