Q: Applet context streams

J

Jacob

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.
 
A

Andrew Thompson

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.
 
T

Thomas Hawtin

Jacob said:
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
 
J

Jacob

Thomas said:
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.
 
A

Andrew Thompson

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.
 
T

Tom Hawtin

Andrew said:
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
 
J

Jacob

Andrew said:
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.
 
A

Andrew Thompson

Jacob said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top