This discussion is archived
5 Replies Latest reply: Jun 15, 2012 10:12 PM by sabre150 RSS

recording data from an applet

942744 Newbie
Currently Being Moderated
Hello,

I am about to start my first java applet project. I have written a game in java and would now like to code it up as an applet to be placed on the web. In the website, the user will play the game by pressing a series of buttons. I want to record what buttons the user pressed and somehow be able to access this data. The user does not need to see the data, and the data does not need to be accessed by the app. Ideally I would like the data written to a text file on my computer. The goal is for me to analyze this data. Before I get started on this project though, I wan't to get a sense of how feasible it is, and what sort of headaches I might encounter etc. I remember reading that apps can not read or write to files, which concerns me.

-Matt
  • 1. Re: recording data from an applet
    EJP Guru
    Currently Being Moderated
    Applets have many security restrictions unless they are signed. See the jarsigner tool and the applet documentation for details.
  • 2. Re: recording data from an applet
    942744 Newbie
    Currently Being Moderated
    so due to the security problems you mention, it seems like what I want to do is impossible without somehow using an HTTP client. Do you know of any good resources on how to use an HTTP client in order to write to a text file on a central server from an applet?
  • 3. Re: recording data from an applet
    sabre150 Expert
    Currently Being Moderated
    939741 wrote:
    so due to the security problems you mention, it seems like what I want to do is impossible without somehow using an HTTP client. Do you know of any good resources on how to use an HTTP client in order to write to a text file on a central server from an applet?
    As I see it all you need is an HTTP server to which the Applet sends the information you wish to record. The Applet will not need to be signed if the Applet is loaded from the same server since an Applet is always allowed to access the server it was loaded from.
  • 4. Re: recording data from an applet
    942744 Newbie
    Currently Being Moderated
    Oh. This is interesting, so all I need to do is have the applet written in the server files, and then when the user loads it on the web page and inputs data, it should be easy to send it back to a file in the server (the one from which the applet was loaded) without any signing required? Can someone verify that this is correct. It seems like all the online references I have encountered make applets writing to files sound way more complicated than this. Why is that?
  • 5. Re: recording data from an applet
    sabre150 Expert
    Currently Being Moderated
    If you are writing files on the client machine then you need to sign the Applet. If you are writing files on the server machine then you will need to write a Servlet ( or maybe a CGI script if you are using a simple HTTP server and not a Servlet engine) that will do the a actual writing of the file to the disk and your Applet will send the data to the Servlet (probably using URLConnection since that makes it easy).

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points