<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
。紈eb-app>
。糳isplay-name>My Web Application</display-name>
<description>
A application for test.
。/description>
。/web-app>
5.在myapp下新建一個(gè)測(cè)試的jsp頁(yè)面,文件名為index.jsp,文件內(nèi)容如下:
<html>
<body>
<center>
Now time is: <%=new java.util.Date()%>
</center>
</body>
</html>
6.重啟Tomcat
package test;
public class TestBean{
private String name = null;
public TestBean(String strName_p){
this.name=strName_p;
}
public void setName(String strName_p){
this.name=strName_p;
}
public String getName(){
return this.name;
}
}
2 .編譯
<%@ page import="test.TestBean" %>
<html>
<body>
<center>
。%
TestBean testBean=new TestBean("This is a test java bean.");
%>
Java bean name is: <%=testBean.getName()%>
</center>
</body>
</html>
5 .好了,重啟Tomcat,啟動(dòng)瀏覽器,輸入http://localhost:8080/myapp/TestBean.jsp 如果看到輸出Java bean name is: This is a test java bean.就說(shuō)明編寫(xiě)的Bean成功了。