Creating Applet reading/writing to file

M

michael.rygh

I'm pretty sure you can do this but for my final project I'm gonna make
an applet thats like a quiz thing and I want the persons final results
to be saved to a file. so then next time someone plays, the high scores
can be read from the file and they can see how they rate againts other
people.

Just making sure.. is this something that can be done using an applet
or do I have to do something special? thanks for the help!
 
R

Rhino

I'm pretty sure you can do this but for my final project I'm gonna make
an applet thats like a quiz thing and I want the persons final results
to be saved to a file. so then next time someone plays, the high scores
can be read from the file and they can see how they rate againts other
people.

Just making sure.. is this something that can be done using an applet
or do I have to do something special? thanks for the help!
Roedy Green has some very useful articles about applets at his site; you
should definitely look at them, particularly this article to start:
http://mindprod.com/jgloss/applet.html. Pay special attention to the section
on Unsigned Applet Restrictions. Now, this may tempt you to write a signed
applet but don't make that decision until you investigate all the
rigamarole - and possible expense - involved in creating a signed applet at
http://mindprod.com/jgloss/signedApplets.html.

You may want to rethink your project and make it a servlet or JSP, rather
than an applet. In any case, you should be well aware of the implications if
you decide to go with an applet before you invest any significant time in an
applet solution.

Rhino
 
O

Oliver Wong

I'm pretty sure you can do this but for my final project I'm gonna make
an applet thats like a quiz thing and I want the persons final results
to be saved to a file. so then next time someone plays, the high scores
can be read from the file and they can see how they rate againts other
people.

Just making sure.. is this something that can be done using an applet
or do I have to do something special? thanks for the help!

If you convert your Applet to an Application, and then deploy it with
Java Web Start, then it's "almost as easy", for the client's point of view,
to run as an Applet, and you yet you can take advantage of "Services"
provided by the JNLP:

http://java.sun.com/developer/technicalArticles/Programming/jnlp/

Note the "DownloadService" which can be used to cache local resources, and
the "FileSaveService". All of this while avoiding the hassles involved in
signing an Applet.

- Oliver
 
M

Malte

I'm pretty sure you can do this but for my final project I'm gonna make
an applet thats like a quiz thing and I want the persons final results
to be saved to a file. so then next time someone plays, the high scores
can be read from the file and they can see how they rate againts other
people.

Just making sure.. is this something that can be done using an applet
or do I have to do something special? thanks for the help!

Having the applet communicate with the server is no problem. If nothing
else, you can use http tunneling and write to a file or a database on
the server.
 
R

Roedy Green

Just making sure.. is this something that can be done using an applet
or do I have to do something special? thanks for the help!

There are two basic approaches.

1. you save to a local file. This requires a signed applet. The
Applet then sees the scores only of people that played on that
machine.

2. you save the data to a server. This requires writing some server
side code, e.g. a Servlet.
 
A

Andrew Thompson

Oliver Wong wrote:
.....
If you convert your Applet to an Application, and then deploy it with
Java Web Start, then it's "almost as easy", for the client's point of view,
to run as an Applet, and you yet you can take advantage of "Services"
provided by the JNLP:

If you JWS an applet you can also access the same services..
Note the "DownloadService" which can be used to cache local resources, and
the "FileSaveService". All of this while avoiding the hassles involved in
signing an Applet.

[ ..but I see no point for this to be an applet, in any case. ]
 
O

Oliver Wong

Andrew Thompson said:
Oliver Wong wrote:
....

If you JWS an applet you can also access the same services..

My understanding was that if you use JWS with an applet, you had to sign
the applet, and so the user would have to say whether or not (s)he trusts
the signature. Trusting the signature in this situation gives full control
to applet, creating an "all or nothing" situation.

In contrast, using JWS with an application, you can request specific
services, and JWS would tell the user WHICH services were being requested,
so that the user could give the application only partial control over the
system.

But this is only from reading (somewhat vague) documentation, and I
haven't actually tested this in code, so I may be wrong.

- Oliver
 
A

Andrew Thompson

Oliver said:
My understanding was that if you use JWS with an applet, you had to sign
the applet,

...and so the user would have to say whether or not (s)he trusts
the signature. Trusting the signature in this situation gives full control
to applet, creating an "all or nothing" situation.

Same applies to JWS'd applets and applications, they either request
all-permissions or none - there is nothing in between.
In contrast, using JWS with an application, you can request specific
services, and JWS would tell the user WHICH services were being requested,
so that the user could give the application only partial control over the
system.

Nope, see above.
 
A

Andrew Thompson

Andrew Thompson wrote:

(Oliver W.)
Nope, see above.

When you throw permissions set in 'policy files' into the mix,
your comments make more sense.

People may have been used to allowing applets (or applications)
particular permissions via the policy files, whereas JWS is 'all
or nothing'.
 

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,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top