Say I have a pac-man applet and I have a counter that increments every time a dot is eaten, and I want to save that for every player, for every game, so there will be a total number of dots eaten from everybody combined. The counter will never reset, just get larger. I want to use this number so I could put something on my web page like "123456 Dots Eaten Since June 2010" or something like that.

All I have is just a counter variable that keeps track of the dots for just one game at a time. Do I need to use a database or just use printWriter or something and keep a txt file to save the counter variable from game to game?

as your applet is run inside a web browser, what about using the browser's cookie ? The advantage is that you won't need any server-side code.

Here is a snippet that explains how it can be done.

'd be interested how to do it too. sounds like he wants a global save from all games on all computers the total dots. saving to a cookie would be local.

Yeah, thanks for the help, but I need more of a global save. I thought about a txt file, but there would be several users writing to the file at one time and the counter wouldn't be accurate, even though a few dots really doesn't matter. Any other ideas?

I need more of a global save

That implies that you need a server to save the scores for all the users.

That implies that you need a server to save the scores for all the users.

Right. What would be the best way of doing that?

Find a server that will allow you to execute code capable of writing to a local disk.
There are some that have perl and some with PHP.
Then write some code for the server to send/receive data to your applet.

i'm interested in the same issue. Does the applet have permission to write to its domain or origin? like myDomain.com is the applets domain can you just write to myDomain? are there security issues? could the applet on close do a post to a page on your domain? and you set up your domain page to parse the post info to a database?

Mike

The applet would not WRITE to a disk file. It would send a message via a Socket to code on a server. Whether the code on a server uses a database depends on what's available on the server.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.