Re: Sun officially deprecates Applets
- From: "Richard Maher" <maher_rj@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 2 Dec 2006 19:34:40 +0800
Hi Jacob,
Thanks for the reply.
"Jacob" <jacob@xxxxxxxxx> wrote in message
news:xaednZkbctNN2OzYRVnzvA@xxxxxxxxxxxxxx
Andrew Thompson is a troll and is best ignored.
Fair enough, thanks for the heads-up, but you couldn't take a few minutes to
take a stab at my original question could you?
That is, "How can I best manage a tcp/ip socket network connection so that
it can persist during page changes".
Regards Richard Maher
Complete original question follows: -
Let me start by stating the basic requirement: - In a browser environment, I
wish to connect to a server (other than the html webserver that is hosting
the page) via a TCP/IP socket and exchange messages when and as needs be
but, once established, keep the connection open to the server until the
browser instance is shutdown. Ideally, I think I'm looking for something
that can work with html -> Javascript -> Java Applet. The user must ne free
to jump from page to page and tab to tab while the network connection lives.
Solution 1. Java Applet - Init() and Destroy()
Use the Init() method to create the socket and connect to the server and the
Destroy() method to close the socket. This seemed to be a perfect match to
my requirements! Until someone pointed out to me that almost all (see list
below) browsers call the Destroy() method whenever a new page is displayed
:-( This is *totally* at odds with all documentation I've seen for the
Destroy() method. What is the difference between Stop() and Destroy() if the
latter is called at *every* page change. Is it only 'cos I'm *not* using a
seperate thread for the Applet? Is there a Browser setting that controls
this?
Solution 2. Java Applet - Init() and never close.
If I ignore Destroy() altogether and simply stick a "if not
mysocket.isConnected() then" in the Init() method, and never *explicitly*
close the socket then that should work shouldn't it?
Two questions (at least) immediately spring to mind: -
(a) Will the Socket *ever* get closed (even when the browser is closed) and
the JVM collect the garbage, or will it simply leak resources until the
client runs out of sockets or memory?
(b) If the page and/or Applet is reloaded will the memory containing the
Socket structure be reinitialized and a false negative be returned to
isConnected() even though the other socket is still there?
Public/Private/Static/Session Variables needed?
Solution 3. Frames
Put the Applet in a seperate (possibly invisible) frame that is never
changed and therefore the Destroy() is never called until browser exit?
Solution BEST. *Please* tell me!
Surely this is not rocket science? I simply wish to fire up a page which
loads an applet, connect to the server, and keep that connection up and
ready for action no matter what the user does (short of closing the
browser). I simply cannot be Christopher Columbus here! Please advise how
best to achieve this functionality.
I'm not great with Java or OO code in general but for a complete discussion
of what I'm attempting you can look at the following thread: -
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1071300
Thanks!
Cheers Richard Maher
PS. Please *don't* discuss AJAX or Java Web-Start or your personal favourite
way of doing things. I know enough (barely :-) to know that my request is
both reasonable and valid; please try to anser *the question*.
List of browsers that call Destroy prematurely: -
Browser Platform Version Comment
Firefox Linux 1.5.0.8 calls destroy when change page
Netscape Linux 7.1 (very old version) calls destroy when change page
Konqueror Linux 3.0.3-13 (very old version) does not call destroy but the
page does not work!
Opera Linux 6.1 (very old version) crash!
Explorer XP 6.0 calls destroy when change page, the page does not work due
an javascript error
Opera XP 8.51 does not work due security
Richard Maher wrote:well be
I'm new here and don't recognize any names, so Andrew Thompson could
the resident Applet Guru
Andrew Thompson is a troll and is best ignored.
.
- Follow-Ups:
- Re: Sun officially deprecates Applets
- From: Chris Uppal
- Re: Sun officially deprecates Applets
- From: Andrew Thompson
- Re: Sun officially deprecates Applets
- References:
- Best strategy for Applets, Sockets, Frames, Destroy(), isConnected() and more . . .
- From: Richard Maher
- Re: Best strategy for Applets, Sockets, Frames, Destroy(), isConnected() and more . . .
- From: Andrew Thompson
- Sun officially deprecates Applets
- From: Richard Maher
- Re: Sun officially deprecates Applets
- From: Jacob
- Best strategy for Applets, Sockets, Frames, Destroy(), isConnected() and more . . .
- Prev by Date: Re: Can my Applets be (mis)used offline?
- Next by Date: Re: Sun officially deprecates Applets
- Previous by thread: Re: Sun officially deprecates Applets
- Next by thread: Re: Sun officially deprecates Applets
- Index(es):
Relevant Pages
|