Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Q: Applet context streams

Reply
Thread Tools

Q: Applet context streams

 
 
Jacob
Guest
Posts: n/a
 
      12-29-2006
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.
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      12-29-2006
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.

 
Reply With Quote
 
 
 
 
Thomas Hawtin
Guest
Posts: n/a
 
      12-29-2006
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
 
Reply With Quote
 
Jacob
Guest
Posts: n/a
 
      12-29-2006
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.
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      12-29-2006
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.

 
Reply With Quote
 
Tom Hawtin
Guest
Posts: n/a
 
      12-30-2006
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
 
Reply With Quote
 
Jacob
Guest
Posts: n/a
 
      12-30-2006
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.
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      12-30-2006
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Spring context refering to application context Jani Tiainen Java 3 08-27-2007 07:24 AM
return HttpStatusCode.ServiceUnavailable in the context.context.Response.StatusCode (Http response code 503) Flip Rayner ASP .Net 1 01-23-2007 06:35 AM
How to retrieve a session Bean in the Context in a class with the Context reference asd Java 1 11-09-2006 05:00 PM
Strange Context Error: Context 0x197ee0 is disconnected in VS 2005 =?Utf-8?B?U3VuU21pbGU=?= ASP .Net 0 01-10-2006 03:59 PM
Context.Items vs Context.Handler (passing values between pages) VS_NET_DEV ASP .Net 2 05-25-2004 01:16 PM



Advertisments