package examples.servlets; /* * @(#)AppletServlet.java 1.15 96/06/21 * * Copyright (c) 1995 Sun Microsystems, Inc. All Rights reserved Permission to * use, copy, modify, and distribute this software and its documentation for * NON-COMMERCIAL purposes and without fee is hereby granted provided that * this copyright notice appears in all copies. Please refer to the file * copyright.html for further important copyright and licensing information. * * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, * OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR * ITS DERIVATIVES. */ import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import weblogic.html.*; /** * This servlet returns an applet embeded in its response htmlKona page. * * @author Adapted for WebLogic, Copyright (c) 1995 Sun Microsystems, Inc. */ public class AppletServlet extends HttpServlet { public void service(HttpServletRequest req, HttpServletResponse res) throws IOException { String line; res.setContentType("text/html"); ServletPage page = new ServletPage("An Applet-invoking Servlet Demo"); // Add an applet tag that will load an applet onto the page. /**REPLACE MyApplet.class WITH YOUR OWN APPLET!*/ AppletElement ap = new AppletElement("MyApplet.class", 1800, 200, AlignType.left); ap.setCodeBase("http://localhost:7001/classes/") .addElement(new ParamElement("text", "This servlet loads applets!")) .addElement(new ParamElement("speed", "4")); page.getBody() .addElement(MarkupElement.BeginParagraph) .addElement("Place your favorite applet .class file in a subdirectory of your classes directory.") .addElement("Be sure that its location in the class directory reflects its package name.") .addElement("(e.g. an Applet with the package type of examples.Applet would be found in classes/examples/MyApplet.class)") .addElement(MarkupElement.BeginParagraph) .addElement("This example will not work unless you have edited line 41 of the AppletServlet.java file to reflect your own applet, and recompiled this file") .addElement(" and placing it and your applet class file into the correct directory") .addElement(MarkupElement.BeginParagraph) .addElement("If you get \"Applet can't start: error: " + "Java.lang.ClassFormatError\" at the bottom of your screen, " + "WebLogic is incorrectly configured to serve this applet. " + "Please check our Tech Tips on ") .addElement(new AnchorElement("../../techsupport/codebase.html", "Troubleshooting CODEBASE")) .addElement(" and ") .addElement(new AnchorElement("../../techsupport/appletsecurity.html", "Troubleshooting Applet Security.")) .addElement(MarkupElement.BeginParagraph) .addElement(ap); page.output(res.getOutputStream()); } }