• Post Reply Bookmark Topic Watch Topic
  • New Topic

Applet - Servlet Communication  RSS feed

 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


Please help. Have been searching the net for months but no avail. I am a novice in Java.

I have an application running on applets. Upon login through my main applet, it will initialises and assign values to all the variables, including all static variables. These variables are not only string variables. My issue is upon successful login, I want to move to my servlet, which I used showDocument(url_of_my_servlet, frame). However in my servlet, all the values in the variables, including static variables are lost. How can I, from my servlet access all the variables and methods set in the applet? By the way, I did not destroy my applet.

Kindly help me.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Uniform Nescafe",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have updated my profile.

Apologize.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Applet-to-servlet communications is a subject that has come in this forum on many previous occasions. Have you looked through previous topics on the subject?
 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


i have looked through. However it is just that my situation is different from others as they can pass those parameters through HttpURLConnection. I cant as my parameters cannot be serialised. Many static java objects are created at the applet side, including the connection pool from database.

Hope you understand.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the objects are not serializable, then they can't be transferred to the servlet. Things like network connections in particular (which is what a connection pool is), are specific to the machine where they are created.
 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

which means they cannot be transferred to the Servlet?

Is there anyway, besides transferring, in which the variables in Applet can be accessible to the Servlet? Which is to say, can put both Applet and Servlet in the same context, or package, so that all of them are public to each other?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Applets run on the client, while servlets run on the server, so they're in different JVM instances. There is no way one can access the other w/o some kind of serialization.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cant as my parameters cannot be serialised.

Well then you better rethink your application design - your present impass is trying to tell you something.
Bill
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why use an Applet/Servlet hybrid in the first place?
 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


actually my application is all solely on Applet. However the login page (build from applet) and all the security and common classes are in terms of applet and many applications are using these classes. My boss wished to change just ONE application to servlet and the rest remains as applet application. I cannot change the Login/Common/Security classes as the rest of the applications are still using these classes. Which is why I need to develop some design that can fit to both applet and servlet.

The login page (applet) will initialises all the variables (just like the existing system). After which my servlet will be loaded based on showDocument(). The servlet should be able to access all these static variables.

Any ideas?

Thanks.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like there are dependencies between the security/login classes and tha fact that they are running in an applet. Try to redesign the classes so that those clases don't depend on their environment (i.e., whether it's an applet or a servlet), so that they can be used in both.
 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply.

you are right, there are dependencies. I am trying to change the common classes so that it works for both applet and servlets.

However kindly provide ideas if there are.

Thanks so much
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there anything in these security/login classes that is inherently impossible to serialize?
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!