下面是applet.jsp代码,主要说明了<applet>的用法
<%@ page contentType="text/html; charset=GB2312"%>
<%@ page language="Java" %>
<HTML>
<HEAD>
<TITLE>利用<applet>载入applet</TITLE>
</HEAD>
<BODY>
<CENTER>
<FONT SIZE = 5 COLOR = blue>利用<applet>载入applet</FONT>
</CENTER>
<BR>
<HR>
<BR>
<CENTER>
<!-- 载入applet -->
<applet code="HelloWorld.class" height="50" width="320" >
<param name="name" value="Applet Demo">
</applet>
</CENTER>
<BR>
</BODY>
</HTML>
其中HelloWorld.class是HelloWorld.java编译以后的文件,HelloWorld.java代码如下:
import java.applet.Applet;
import java.awt.Graphics;
public class HelloWorld extends Applet
{
String name;
public void init()
{
name = getParameter("name");
}
public void paint(Graphics g)
{
g.drawString(" This is " + name + "!", 60, 25);
}
}
<%@ page contentType="text/html; charset=GB2312"%>
<%@ page language="Java" %>
<HTML>
<HEAD>
<TITLE>利用<applet>载入applet</TITLE>
</HEAD>
<BODY>
<CENTER>
<FONT SIZE = 5 COLOR = blue>利用<applet>载入applet</FONT>
</CENTER>
<BR>
<HR>
<BR>
<CENTER>
<!-- 载入applet -->
<applet code="HelloWorld.class" height="50" width="320" >
<param name="name" value="Applet Demo">
</applet>
</CENTER>
<BR>
</BODY>
</HTML>
其中HelloWorld.class是HelloWorld.java编译以后的文件,HelloWorld.java代码如下:
import java.applet.Applet;
import java.awt.Graphics;
public class HelloWorld extends Applet
{
String name;
public void init()
{
name = getParameter("name");
}
public void paint(Graphics g)
{
g.drawString(" This is " + name + "!", 60, 25);
}
}