This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Game Development and the fly likes Saving state in an applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "Saving state in an applet" Watch "Saving state in an applet" New topic
Author

Saving state in an applet

Mich Robinson
Ranch Hand

Joined: Jun 28, 2009
Posts: 250
    
    1
I'd like to be able to save the current game (of chess) in my applet but I'm not sure on the easiest way. I could communicate to a database but this seems like overkill. I could call a local web page that perhaps stores the game but again this looks quite difficult.

Is there an easy way of writing a string (about 300 char length) to the browser and letting it return it when that user next goes to the page. Any ideas?


Arcade : Alien Swarm
Board : Chess - Checkers - Connect 4 - Othello
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41591
    
  55
Check out the various *Stream* methods in AppletContext. I've heard people report mixed successes with this, though.


Ping & DNS - my free Android networking tools app
Andrew Thompson
Ranch Hand

Joined: Aug 05, 2010
Posts: 77
    
    5
Mich Robinson wrote:I'd like to be able to save the current game (of chess) in my applet but I'm not sure on the easiest way. ..

Is there an easy way of writing a string (about 300 char length) to the browser and letting it return it when that user next goes to the page. Any ideas?


  • If the user's browser is running a Plug-In2 Architecture JRE, use the PersistenceService of the JNLP API.
  • Earlier JREs might store a cookie with the help of JS.
  • HTML 5 offers Local Storage.
  • A trusted applet can store the settings on the local file system.


  • Andrew Thompson
    http://pscode.org/
    Mich Robinson
    Ranch Hand

    Joined: Jun 28, 2009
    Posts: 250
        
        1
    Are these techniques common?
    ie would most browsers support them?
    What happens if they're not supported?

    PS I don't have any control over user's browsers.
    Andrew Thompson
    Ranch Hand

    Joined: Aug 05, 2010
    Posts: 77
        
        5
    Mich Robinson wrote:Are these techniques common?
    ie would most browsers support them?
    What happens if they're not supported? ..


    The answer to each question is 'it depends on the technique you are referring to'. I am not about to write a treaties covering all possibilities. Be more specific and put some research in, before I'll offer any more.

    Mich Robinson wrote:..PS I don't have any control over user's browsers.


    And that is a good thing. If web/server side developers start thinking they have any right or power to control the user or their browser, things go down hill rapidly.
     
     
    subject: Saving state in an applet