• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

applet info sharing.

 
jeff ukridge
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe I don't need to use cookies for this (or maybe I do).

On a series of web pages, I have a handful of applets. All these applets share the same code base.

The problem is a basic one. I need to get information from one applet to another.

Let's say I have a LOGIN applet that gets the username from the user (on the index.html page). That applet has an OK button that will load the doWork.html page that has an applet on it called WORK. I want to get the username from the LOGIN applet to the WORK applet.

After reading this:

http://www.javaworld.com/javatips/jw-javatip101_p.html

It seems to me that all I need to do is to have a reference to the LOGIN applet from within the WORK applet and simply invoke the loginApplet.getUserName() method to retrieve the data.

This seems too simple...am I missing soething here?

Here are some code fragments of what I'm planning to implement:

step 1. set up the reference to the LOGIN applet in the LOGIN applet.


Step 2. in the WORK applet, get the LOGIN applet reference.'



Step 3. From within the WORK applet, get the user name data




Is this a sound approach? What if the user tries to access the WORK page before going through the LOGIN (index.html) page first? What happens when the user hits the refresh button or the back button on his browser? What happens if the user is using a tabbed browser and logs in simultaneously as different users on differet tabs (from the same browser)?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This approach depends on the fact that only a single JVM is used for all applets in a browser, and that it uses the same ClassLoader for all applets. Both of these are assumptions that may be true for a particular JVM/browser combination, but neither is specified as being required. So the fact that it works for you is not indicative of whether it will work for the next guy. Whether or not that is an acceptable tradeoff is for you to decide.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic