The applet life-cycle specification is vague, perhaps intentionally. In the past, different browsers had quite different behaviors. I think the consensus those days is that what you see is the most logical behavior.
Otherwise the question arrises: for how long should we keep the applet alive. And how many such invisible and perhaps useless applets that tie system resources, perhaps with bad intentions?
Here is what I would suggest. Have two signed applets in your page.
- Free floating (or JWS application)
- Single instance
- Reads the serial port
- Listens on a TCP port like 12345
- The point is that once launched, browser navigations won't affect it.
- Data read from the serial port is written to the TCP connection, if any.
- Traditional, stays in the page
- On init() or start(), opens a TCP connection to port 12345.
- Over the TCP connection, it reads the serial port data.
Javacript will talk to Applet 2.
Of course, there are some questions to answer before embarking:
What Applet 1 does with the data if Applet 2 disconnects (user moves away from the page or closes the browser)? Discards it? Buffers it? How much, for how long?
When should Applet 1 exit?