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 / December 2006

Tip: Looking for answers? Try searching our database.

Q: Applet context streams

Thread view: 
Jacob - 29 Dec 2006 09:08 GMT
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.
Andrew Thompson - 29 Dec 2006 09:52 GMT
...
(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.
Thomas Hawtin - 29 Dec 2006 15:49 GMT
> 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
Jacob - 29 Dec 2006 18:59 GMT
> 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.
Andrew Thompson - 29 Dec 2006 20:46 GMT
...
> 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/PersistenceServ
ice.html
>
<http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/examples.html#P
ersistenceService
>

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

Andrew T.
Tom Hawtin - 30 Dec 2006 00:38 GMT
> Web-started applications (and applets) do not need
> to be signed in order to store preferences, since even
[quoted text clipped - 3 lines]
> <http://java.sun.com/j2se/1.5.0/docs/guide/javaws/jnlp/javax/jnlp/PersistenceServ
ice.html
>
> <http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/examples.html#P
ersistenceService
>

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
Jacob - 30 Dec 2006 08:45 GMT
> 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.
Andrew Thompson - 30 Dec 2006 10:27 GMT
> > Web-started applications (and applets) do not need
> > to be signed in order to store preferences, since even
[quoted text clipped - 5 lines]
> 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.


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.