• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to maintain an applet state?

 
SoonAnn Lim
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i maintain applet state on client browser without using cookie? I am trying to avoid using netscape's api to access cookie information at client side. Any idea?
Thanks.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
can u explain in more details what you want to achieve?
what i can think of is,
-write a servlet that stores applet status information on the serverside in someobject
-communicate the applet with that servlet to get the applet's previous status information
but here you have to have some way to have client's identity so that you an associate the applet's state with a particular client. may be this id is the user who logged on or the IP address or something else which is making a user unique to ur application....
if we don't do this than i hope u understand what the problem might be...
i don't know if u want to write a servlet or not but if u don't want to use netscape api to access cookies on the client side then the servlet seems the option as applet will have to store the state outside it for sure (as it doesn't have setAttribute() getAttributes() methods as they are there in the servlet api).
other way, i would suggest is,
make the applet signed and enable it to write a file to the client side and store information on the client side....
let me know if u find any better solution and also try to explain me what exactly you want to have as a state of the applet?? (may be the user prefrences i guess for the applet)
regards
maulin
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i just found a link which might be helpful if u plan to use jdk1.4.
http://java.sun.com/j2se/1.4/docs/guide/plugin/developer_guide/persistence.html
they added methods in AppletContext for the persistance maintenance...
regards
maulin
 
SoonAnn Lim
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to implement a unique web access counter similar to visitor counters
that we see at most web pages. I am doing it in an applet. The idea is when the applet
is loaded, i will have some sort of id for this particular visitor(can easily be done
using cookie via servlet). When browser leave the page, applet is unloaded and destroyed.
At this stage, applet will send back its own identification, which is its id, to the server.
Based on id, i can identify whether this is a new visit or a repeated visit. In order to do
this, i need to use a cookie. However, i avoid netscape api to minimize browser compatibility
issue.
It seems to me that cookie is the only way to acheive this. Unfornately, applet does not
work very well with cookie. I don't have a good solution yet. It appears to me this is a very
common problem in Java community. Most people use netscape api as solution.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
but if u just need a unique id then why don't u use IP address of the access as an id? so if a user uses the same computer with static id then u can know about his/her revisit.
if u want to have unique id for users even if they use ur applet may be from dynamic IPs (ISPs) or from different computers then u need to have 'USERNAME' and 'login' mechanism i guess. w/o that u can't make it.
after u have a way to determine unique id then u can apply some idea i suggested earlier or some other way...
regards
maulin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic