Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp using applet

 
Pinda Ros
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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"

Any suggestions?

Thank in advance

pinda
 
Eugene Lucash
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When browser load applet it calls applet's init() method. When page is unloaded
(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.

regards
 
Pinda Ros
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello and thank you for the reply.

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?

Thank you
 
Eugene Lucash
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If page is readonly, then you can load it in applet from the 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.
 
Pinda Ros
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
Eugene Lucash
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Applets and Servlet/JSP has no any default connection between each other.
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.....

regards
[ February 24, 2005: Message edited by: Eugene Lucash ]
 
Pinda Ros
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello and thank you for the reply.

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?


Regards

 
Eugene Lucash
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunetly you can't save applet from 'destroying' on refresh.
So you must manually save notepad's data on server (temporarily) and restore it untill user logout

it is a shortcoming of applet approach

regards
[ February 24, 2005: Message edited by: Eugene Lucash ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64858
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This seems to be much more about Applets than JSP, so it is being moved accordingly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic