下面是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);
}
}
闽公网安备 35060202000074号