A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Applets
Author
passing a parameter from servlet to applet
Brian Snyder
Ranch Hand
Joined: Feb 03, 2001
Posts: 142
posted
May 29, 2001 09:27:00
0
Hey all. I'm having a bit of a dilema.
I have an
applet
whose init() contains:
public void init {... resized = getParameter("resized"); System.out.println("The value of resized=" + resized); if (resized != null)loadBaseApplet(); else getContentPane().add(getLoginBox(), BorderLayout.CENTER); ... }
Here's how the
servlet
gets called from within the applet...
public void resizeApplet() { resized = "t"; try { getAppletContext().showDocument(new URL("http://localhost:8080/servlet/ResizeApplet"), "_self"); } catch (Exception ignored) {} }
I am getting the parameter "resized" from some html that was written from a servlet. Here's the code for that...
import java.io.*; import java.util.*; import java.net.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; import javax.swing.*; public class ResizeApplet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println("t"); out.println("<html>"); out.println("<head>Welcome to Wassail!!</head>"); out.println("<title>Nice!</title>"); out.println("<body>"); out.println("<center><h1></h1></center>"); out.println("<CENTER>"); out.println("<p>"); out.println("<p>"); out.println("<p>"); out.println("<p>"); out.println("<p>"); out.println("<OBJECT classid=\"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\""); out.println("WIDTH = 500 HEIGHT = 400 codebase=\"http://java.sun.com/products/plugin/1.2/jinstall-12-win32.cab#Version=1,2,0,0\">"); out.println("<PARAM NAME = CODE VALUE = \"appl.MemberApplet.class\" >"); out.println("<PARAM NAME=\"type\" VALUE=\"application/x-java-applet;version=1.2\">"); out.println("<EMBED type=\"application/x-java-applet;version=1.2\" WIDTH = 500 HEIGHT = 400 pluginspage=\"http://java.sun.com/products/plugin/1.2/plugin-install.html\""); out.println("CODEBASE=/ CODE = \"appl.MemberApplet.class\" "); out.println("<PARAM NAME = \"resized\" VALUE = \"t\" >"); //HERE'S WHERE I INSERT THE PARAMETER!!!!!! out.println("</EMBED>"); out.println("</OBJECT>"); out.println("<p>Our objective:"); out.println("<p>Have Fun!, Stay Together!, and Make Money!!!!"); out.println("</CENTER>"); out.println("</body>"); out.println("</html>"); } }
The problem is that whenever the applet is reloaded the parameter is not being recognized.
Many thanks in advance for your help!!!
[This message has been edited by Brian Snyder (edited May 29, 2001).]
Brian Snyder
Ranch Hand
Joined: Feb 03, 2001
Posts: 142
posted
May 29, 2001 11:30:00
0
I found the problem.
I had to use <param user="uuu">
not
<param name=user value="uuu">
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: passing a parameter from servlet to applet
Similar Threads
A parameter from servlet to applet
One HTML for running JApplet for both IE and NS
JApplet not working properly in Web browser
parameter to applet problems
Game Tutorials -->> Exploring Browser Support for Java 2
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter