Saturday, August 6, 2011

Forum Comments on Java Applets

It is so long since I last posted on the once was Sun/Java now is Oracle developer forum my account seems to have been ditched. While I wait to have it resurrected I've done a little searching in the Java Database Connectivity (JDBC) forum using the search term "Applet".

My first search, using the default 3 month period, yielded nothing. No one had posted anything about or even mentioned Applets in the last three months. So either they are very easy to use and work very well, so hardly anyone has any problems with them, or maybe ... not very many people use them at all.

My stomach was beginning to churn a bit, when I extended the search period to the current year - and with good reason. Somebody, a little bit like me I think, had written a game in an applet, and wanted to record top scores in a database. He described his connection problem in this thread, and the first reply began:

Doing JDBC calls from an Applet is such a bad idea that I am glad you are having trouble with it. You might want to reconsider your design! If you persist on going this way, I can tell you that there will be many more even more difficult hurdles that you will need to overcome which would make this problem seem like a piece of cake ...

The OP opened his question with the phrase:

I'm trying to write a very basic test applet ...

One reply to this specific phrase was:

You may as well be hunting unicorns. Applets are never easy.

Another reply, to the post as a whole began:

Apart from the bad idea of connecting to your db from an applet (security is one that springs to mind ...

and concluded his reply with:

...Exactly how this wires up for an applet I can't say since I've not written one in a decade.

So perhaps 10 years ago Applets were "hip" for whatever reason, but now they seem definitely not to be.

Another thread actually opened with a quote from another website, inviting comments and clarification. The quote was:

It is generally not a good idea to use JDBC directly in an Applet. You need to presume some brat will decompile your Applet and use that knowledge to create a substitute Applet that causes as much havoc as possible. If your Applet has direct access to JDBC, the brat’s substitute can snoop or pillage the database to its heart’s content.

Most of the posts are pretty uncomplimentary about Applets and the ODBC-JDBC bridge (which I looked at but gave up on because it was too hard to get it to work), but one of them suggests a solution using servlets:

What you could do is write two servlets. One is called "gimmethescores". The applet calls and gets a list of high scores to display. You can use a simple line by line text format, or XML, or whatever you wish.

The other servlet is "setscore". After the game is over, the applet calls The servlet then checks the parameters look sane and updates the high score table.

So now I'm thinking I need to study up on servlets.

No comments: