I do not know if this question should be here or in the applets forum but I 'll write it here since I believe its a jsp issue.
I have developed a small notepad applet that works fine with the following problem.
Let's say I open a document (works ok)
If then for some reason the page has to be refreshed, the changes will be lost.
For example the textArea object will be empty instead of having the contents of the document that was open.
The reason for the refresh might be that this applet is part of a portlet portlet itself or part of a bigger web application.
So if the applet for exaple is a portlet maximizing it or restoring it will cause the whole page to refresh causing the applet to lose its "state"
Thank in advance
(before refresh or navigation to another page) browser calls applet's
destroy() method. So lifecycle of applet is lifecycle of contaning page.
So if you want some persistence you (using applet's networking capabilities)
in destroy method must save the state on server, and in init method restore
the previous state if any.
Why save it on the server? If the page is being viewed by 2000 users at the same time this means i should keep 2000 records....
What if the applet was persisted in the clients side for each user and if the session is valid to try and load the persistent state?
Which do you think it is better?
If page is readonly, then you can load it in applet from the same record
for each user.
What exactly do you mean by same record for each user?
As I said before life cycles of applet and html page are almost the same.
So you can create persistent page (that don't reloads) by using frames or popup windows.
I'm not talking about simple html pages but servlets and jsp pages using sessions.
Are you suggesting that jsp using sessions it is not a good practice?
Only thing you can do is to pass parameters between them.
Jsp can send to applet init params, and applet can operate urls to communicate with servlets via it's own networking capabilities(Sockets, Channels, URL) or by operating browser's navigation. Manually plumbing them together is time consuming and error prone task, especially with HttpsSessions.
I recommend to use applets with servlets/jsp only as some presentational component, but not as part of application logic and behavior.
Otherwise you'll get stuck at.....
[ February 24, 2005: Message edited by: Eugene Lucash ]
Applets and Servlet/JSP has no any default connection between each other.
I have developed a connnection using rmi I omit to mention that this notepad is remote notepad everything that the user does it happens at the server.
For example each logged in user views its own folder with each own files and can open /save file from / to the server.
Thats why I have to minitor when the user really logged out or jsut refreshed the page
Any suggestions on a better practice?