Sure, this should be possible. There are a few options:
1) [Easiest] Your Java applet can send the browser to a new
URL. This URL could include the string e.g. http://whatever/nextpage.php?answer=I+have+typed+something. You can make nextpage.php as a Moodle script which can save the data somewhere in the Moodle
database, or for example carry out other things such as updating a grade in the gradebook. This option only works if your applet is now finished and not needed any more, as changing the page will lose the applet.
2) [Still quite easy] If I remember correctly, your Java applet can make network requests as long as they are to the exact same
server the applet is running on, without even having to sign the applet. Since that's what you want to do, it's all good. So you can make your Java applet request a URL on your server, such as http://whatever/storedata.php?answer=whatever - this can use the normal Java URL request mechanisms, so you can do a POST instead if you need to store a lot of data.
3) [Harder] If you sign your Java applet - this will require a paid-for SSL certificate, and the user will have to click an 'agree' button of some kind - then it can do anything you like such as connect to arbitrary servers. I don't think you need this (but you might if I'm wrong and it won't let you do the suggestion in #2).
If you hit a restriction that means Java won't let you do something for security reasons (ie you would need to sign the applet to allow it) that will be a SecurityException, so you can tell whether you're hitting that problem or something else.
The remaining question is how to write the Moodle script involved. This should be fairly easy - one option is to build your applet into a Moodle module ('activity') which both displays the Java applet itself, and provides the back-end infrastructure.
Activities can have database tables which you can use to store the user data.
--sam