初学问题:JSP运行显示问题,内附出错代码!
// FilledBox.html
<HTML>
<HEAD>
<TITLE>Sample HTML DocumentWith Filled Box</TITLE>
</HEAD>
<BODY>
<H1>FilledBox Demo</H1>
<P>
<APPLET CODE="FilledBox.class" WIDTH=200 HEIGHT=60>
<PARAM NAME=color VALUE="blue"> </APPLET>
</BODY>
</HTML>
//CODE 处应该填什么? 是不是应该把FilledBox.class的绝对路径写出来,把
//FilledBox.class拷贝到与FilledBox.html相同的目录下可以么 ,给个例子吧
------------------------------------------------------------------------
//FilledBox.java
import java.awt.*;
import java.applet.Applet;
/** FilledBox displays a filled. colored box in the browser window.*/
public class FilledBox extends Applet
{
//This variable stores the color specified in the HTML document
Color boxColor;
/** Get the box color from the host HTML file.*/
public void init()
{
String s;
s = getParameter("color");
// the default color is gray
boxColor = Color.gray;
// we expect a parameter called color which will hava
//the value red. white or blue. If the parameter
//is missing, s will be null
if(s !=null)
{
if(s.equals("red"))
boxColor = Color.red;
if(s.equals("white"))
boxColor = Color.white;
if(s.equals("blue"))
boxColor = Color.blue;
}
}
/** Paint the box in region asigned to the applet.
Use the color secified in the HTML document */
public void paint(Graphics g)
{
g.setColor(boxColor);
g.fillRect(0, 0, size().width, size().height);
}
}
在IE中输入:http://localhost:8080/jsp/FilledBox.html 在应该出现applet的地方是一个灰框,鼠标移上去提示没有找到FilledBox.class
我应该把FilledBox.class放到哪个目录去
上面的程序都是书上的 如果方便的话给个例子, 多谢!