Servlet Call Applet
Hi there,
I'm new in Java. I have a servlet that want to call applet. It return ClassNotFoundException.
My coding is below.
package com.csb.ocs.servlet;
import java.applet.Applet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class AppletCaller extends HttpServlet {
private static final long serialVersionUID = 1858939761850073093L;
static final int WIDTH = 450;
static final int HEIGHT = 320;
static final String APPLETNAME = "MainApplet";
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
ServletOutputStream out = res.getOutputStream();
Applet applet = null;
try {
// Load the SecondApplet
// Must be in the standard CLASSPATH
try {
applet = (Applet) Class.forName(APPLETNAME).newInstance();
}
catch (Exception e) {
throw new ServletException("Could not load applet:" + e);
}
// Prepare the applet arguments
String args[] = new String[1];
args[0] = "barebones=true"; // run without a menu bar
// Put the applet in its frame
// addNotify() is called by MainFrameModified
}
finally {
// Clean up resources
}
}
}
|