Tomcat5.5
版本
:
(假设都采用默认的配置)
创建目录
: D:\tomcat5\webapps\ROOT\WEB-INF\classes (
存放
JavaBean
包
);
创建目录
: D:\tomcat5\webapps\ROOT\WEB-INF\classes\com
//Bean code File name:bean.class
package com;
public class bean
{
String mName;
public bean()
{
mName="init";
}
public String getName()
{
return mName;
}
public void setName(String s)
{
mName=s;
}
}
//JSP code File name:testbean.jsp
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="com.*"%>
<html>
<head>
<title>Test</title>
</head>
<body>
<jsp:useBean id="hello" class="com.bean"/>
<%
out.print(hello.getName()+"<br>");
hello.setName("
我给了你了
");
out.print(hello.getName());
%>
</body>
</html>