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
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.
[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/