http://localhost:8083/servlet/Applet1.html-->http://localhost:8083/Applet1.html

解决方案 »

  1.   

    不行,应该不是这个的问题,报错依旧,我把resin文档中的例子copy过来设置一下就能
    从http://localhost:8083/servlet/hello访问到我的Applet1.java
    ---------------------------------------
    package testjdbc;import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import org.jfree.chart.*;
    import org.jfree.data.*;
    import java.awt.image.*;
    import javax.servlet.Servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.*;
    public class Applet1 extends Applet {
      boolean isStandalone = false;
      String var0;
      //Get a parameter value
      public String getParameter(String key, String def) {
        return isStandalone ? System.getProperty(key, def) :
          (getParameter(key) != null ? getParameter(key) : def);
      }  //Construct the applet
      public Applet1() {
      }  public void paint(Graphics g){
        DefaultPieDataset pieDataset = new DefaultPieDataset();
        pieDataset.setValue("JavaWorld", new Integer(75));
        pieDataset.setValue("Other", new Integer(25));
       org.jfree.chart.JFreeChart chart1 = org.jfree.chart.ChartFactory.createPieChart("aaa",pieDataset,true,true,true);
       BufferedImage image = chart1.createBufferedImage(500,300);      g.drawImage(image,0,0,this);
          super.paint(g);
      }
      //Initialize the applet
      public void init() {
        try {
          jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }
      //Component initialization
      private void jbInit() throws Exception {
      }
      //Get Applet information
      public String getAppletInfo() {
        return "Applet Information";
      }
      //Get parameter info
      public String[][] getParameterInfo() {
        String[][] pinfo =
          {
          {"name", "String", ""},
          };
        return pinfo;
      }
    }------------------------------------------
    调用他的Applet1.html
    ------------------------------------------
    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GB2312">
    <title>
    HTML Test Page
    </title>
    </head>
    <body>
    testjdbc.Applet1 will appear below in a Java enabled browser.<br/>
    <applet
      codebase = "."
      code     = "testjdbc.Applet1.class"
      name     = "TestApplet"
      width    = "400"
      height   = "300"
      hspace   = "0"
      vspace   = "0"
      align    = "top"
    >
    <param name = "name" value = "FreeChart">
    </applet>
    </body>
    </html>