Q: Applet context streams

Discussion in 'Java' started by Jacob, Dec 29, 2006.

  1. Jacob

    Jacob Guest

    Are applet context streams really persistent between
    browser sessions? I.e.: start a session, load an applet
    which stores information in a file, kill the browser,
    restart browser (one week later), load the applet, and
    the applet will be able to locate the file?

    What is the back-end technology that ensures this feature?
    Can I be sure it works for all java-enabled browsers on
    all platforms and may its behaviour be subject to user
    settings on the client side? Where are these files, for
    instance on a Linux/Mozilla setup?

    Also, why is the API using an InputStream? Seems a bit
    odd to *write* to an input stream?

    I am trying to implement the java.util.prefs.Preferences
    interface by means of applet context streams in order to
    store information on the client without the need for applet
    signing and explicit user approval, but can't get it to work.
    The answers to the above may guide me in the right direction.

    Thanks.
     
    Jacob, Dec 29, 2006
    #1
    1. Advertising

  2. Jacob wrote:
    ....
    (Applet in browser VM)

    > Can I be sure it works for all java-enabled browsers on
    > all platforms ...


    No. That is the simple answer to *any*
    questions relating to 'can I *rely* on X
    applet behaviour in Y browser'.

    There are no guarantees.

    (Not entirely sure on the rest.)

    Andrew T.
     
    Andrew Thompson, Dec 29, 2006
    #2
    1. Advertising

  3. Jacob wrote:
    > Are applet context streams really persistent between
    > browser sessions? I.e.: start a session, load an applet
    > which stores information in a file, kill the browser,
    > restart browser (one week later), load the applet, and
    > the applet will be able to locate the file?


    No.

    Although applet contexts are cached, they are transient in nature.

    > What is the back-end technology that ensures this feature?
    > Can I be sure it works for all java-enabled browsers on
    > all platforms and may its behaviour be subject to user
    > settings on the client side? Where are these files, for
    > instance on a Linux/Mozilla setup?


    There are no files.

    > Also, why is the API using an InputStream? Seems a bit
    > odd to *write* to an input stream?


    Presumably so the implementation could be changed to support huge
    stores. Or perhaps to run on machines with small logical memory sizes.

    Having a look at the implementation: don't pass an InputStream which
    returns anything less than the entire length from the available or read
    methods...

    > I am trying to implement the java.util.prefs.Preferences
    > interface by means of applet context streams in order to
    > store information on the client without the need for applet
    > signing and explicit user approval, but can't get it to work.
    > The answers to the above may guide me in the right direction.


    I would probably take another direction.

    IIRC, preferences doesn't play nicely with JNLP (WebStart) applications,
    let alone browser applets. I guess the best approach for that sort of
    thing is to use cookies (or move to WebStart and use muffins).

    Tom Hawtin
     
    Thomas Hawtin, Dec 29, 2006
    #3
  4. Jacob

    Jacob Guest

    Thomas Hawtin wrote:

    > No.
    >
    > Although applet contexts are cached, they are transient in nature.


    Thanks. This is in line with my own findings
    on the subject. Although I then find no real
    appliance for this feature. (Which is in line
    with the amount of information available on
    the web which is ~0 :)

    I don't have any problems using Preferences
    with JWS or applets as long as the jars are
    properly signed, but I'll give the cookie
    approach a try before I settle the issue.

    Thanks again.
     
    Jacob, Dec 29, 2006
    #4
  5. Jacob wrote:
    ....
    > I don't have any problems using Preferences
    > with JWS or applets as long as the jars are
    > properly signed, ..


    Web-started applications (and applets) do not need
    to be signed in order to store preferences, since even
    a sandboxed app. can make use of the
    PersistenceService.

    <http://java.sun.com/j2se/1.5.0/docs/guide/javaws/jnlp/javax/jnlp/PersistenceService.html>
    <http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/examples.html#PersistenceService>

    (I am currenttly working on a sandboxed app.,
    that does that.)

    Andrew T.
     
    Andrew Thompson, Dec 29, 2006
    #5
  6. Jacob

    Tom Hawtin Guest

    Andrew Thompson wrote:
    >
    > Web-started applications (and applets) do not need
    > to be signed in order to store preferences, since even
    > a sandboxed app. can make use of the
    > PersistenceService.
    >
    > <http://java.sun.com/j2se/1.5.0/docs/guide/javaws/jnlp/javax/jnlp/PersistenceService.html>
    > <http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/examples.html#PersistenceService>


    My memory is a little fuzzy on the issue. If I wanted to store
    Preferences (as in java.util) rather than just common or garden
    preferences, is JNLP happy? I can't remember if it is just a problem
    with all the evil staticness not using 'AppContext' or whether it is
    something more entrenched than that.

    Tom Hawtin
     
    Tom Hawtin, Dec 30, 2006
    #6
  7. Jacob

    Jacob Guest

    Andrew Thompson wrote:

    > Web-started applications (and applets) do not need
    > to be signed in order to store preferences, since even
    > a sandboxed app. can make use of the
    > PersistenceService.


    For JWS applications perhaps.

    I can't get this to work with applets,
    as there is no JNLP instance available.
     
    Jacob, Dec 30, 2006
    #7
  8. Jacob wrote:
    > Andrew Thompson wrote:
    >
    > > Web-started applications (and applets) do not need
    > > to be signed in order to store preferences, since even
    > > a sandboxed app. can make use of the
    > > PersistenceService.

    >
    > For JWS applications perhaps.
    >
    > I can't get this to work with applets,
    > as there is no JNLP instance available.


    ...you do need to *launch* the applet via JWS,
    in order to access the JNLP API services.

    Andrew T.
     
    Andrew Thompson, Dec 30, 2006
    #8
    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. VS_NET_DEV
    Replies:
    2
    Views:
    3,839
    jenny
    May 25, 2004
  2. =?Utf-8?B?U3VuU21pbGU=?=
    Replies:
    0
    Views:
    724
    =?Utf-8?B?U3VuU21pbGU=?=
    Jan 10, 2006
  3. Flip Rayner
    Replies:
    1
    Views:
    738
    bruce barker
    Jan 23, 2007
  4. asd
    Replies:
    1
    Views:
    455
    www.pulpjava.com
    Nov 9, 2006
  5. Jani Tiainen
    Replies:
    3
    Views:
    1,058
    Jani Tiainen
    Aug 27, 2007
Loading...

Share This Page