Applets in html in servelts

I have a problem with a servlet i'm writing.

i'm trying to use the servlet to construct a html page with a java applet GUI inside of it. I'm using the information collected by this GUI to create a new html page that utilizes the collected information. My porblem is that as I understand it to put an applet in an html page I need to place the compiled code there. However I need to pass variables into the applet and modify them so I can get the information (it was the best way I could think of). How can I pass the variables into the applet to collect the information?

html code

GUI (user inputs information

html code

[667 byte] By [darkling235] at [2007-9-26 3:51:04]
# 1

I believe the best route to doing this is through JavaScript, although you can also give an applet parameters through the "param" tags within the applet tag. It is worth considering whether you can do what you plan to do with an applet using just JavaScript/Dhtml stuff, as that is surprisingly powerful and much easier to handle with servlets.

Breakfast at 2007-6-29 12:37:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Yes - I would also suggest u to use HTML forms as GUI instead of Applet and use javascript to set/get the values in the apprpriate fields.
yadavS at 2007-6-29 12:37:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

[darkling235],

I think what you are referring to is applet-servlet communication and passing parameters to the applet.

So we are probably talking about Servlets and Object Serilaization, which is the recommended method to exchange Java objects between a Java applet and Java Servlet since both are written in Java.

However, just by looking at your requirement of your app i.e.:

html code

GUI (to obtain the user inputs and store it into variables)

html code

, you will better off redesigning your application by utilising HTML forms and passing variables to the Servlet using doGet() and doPost() methods.

Can you post your applet and servlet code so as to give us a better idea of what you are trying to achieve with your application?

Allen Lai

Developer Technical Support

SUN Microsystems

http://www.sun.com/developers/support/

allenlai at 2007-6-29 12:37:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...