Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ways to "serialize" when you can't  RSS feed

 
Max Benjamin
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure that this is the right place to ask this question as it concerns an applet but is not necessarily applet specific.

I am trying to work out a way to save object states in an applet so that the next person who downloads the applet will see it in the state it was left by the previous user(images may be repositioned by the user). Unfortunately, my host does not support java and so serializing is not an option. What would be a recommeded way to deal with this issue. Is saving the data in an XML file a good idea? If so, what libs or docs should I look at? Other ideas?

Thanks,
Max
 
Robert Hill
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you would have to have the applet send back the state info to the server. The problem is how to save the state for the next time it is downloaded. Find what languages you can run on your server, probably one of your standard CGI languages(php, python, perl, or even C, although not widely known as a language to interface with CGI), and write a little server program to recieve the state info. Make sure the data is encoded in a way that is easy to read. If you send it back in an ObjectOutputStream for example, you will have a rough time getting another language to parse it properly, and save it in a .txt or binary file, which would have to be sent over the wire to the next computer downloading the applet.

You would also have to deal with synchronization and file lock issues, not to mention the potential serious security issues, you will have to have a good system to make sure a would be hacker doesn't send your server data that can comprimise your server.

All in all it would be a lot of hassles for what is basically a gimick.
 
Srinivas Kalvala
Ranch Hand
Posts: 257
Firefox Browser Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Max Benjamin:

I am trying to work out a way to save object states in an applet so that the next person who downloads the applet will see it in the state it was left by the previous user(images may be repositioned by the user).
Thanks,
Max


what you meant by to save object. Can you give more details ....
 
Max Benjamin
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More details:

The applet takes a string either(I haven't worked out all the details) from a file on the host server or from a parameter in the applet's html. It breaks this string into individual words and an object is created for each word that contains it's name(the individual word as String) and an x position and y position of where it is to be drawn in the applet. The initial set up of the objects(their position) is determined by the font used and applet size. A user can then click and drag on the different words repositioning them on the screen and thus changing their internal x y state. I would like to save these x and y coodinates for each object so that the next user will see what the last user altered and be able to change that.

I was thinking one answer might be to use javascript/java LiveConnect to grab this information from the applet and write it to a file on the server by sending it in a POST request(my host supports ruby, php, python). I could then write the infromation to parameters in the applet's html as strings and then parse out the infromation in those strings when the applet is loaded again.

I'm a noob so any other suggestions are more than welcome. I appreciate those thus far though it's not really "just a gimmick". I think that depends more on the "why" than the "what".

Best,
Max
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
XML would be a great way to get rid of this situation.But this thing depends as how clearvly you can carve out your essential / reconstruction related date into a xml file.Now variety of xml parsers are also available for many languages so dealing with the constructed xml should not be a problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!