webroot/index.jsp
webroot/web-inf/classess/beyond/step/javabean1.class
---------------------------------------------------------------------------------------------------------
<%@ page contentType="text/html;charset=GBK"%>
<%@ page import="beyond.step.javabean1"%>
<html>
<head>
<title>
测试JAVABEAN
</title>
</head>
<jsp:useBean id="zmsbean" scope="request" class="beyond.step.javabean1"/>
<jsp:setProperty name="zmsbean" property="name" value="setdefaultname"/>
<body>
<h1>
use java bean in jsp
</h1>
<%
out.println(zmsbean.getName());
zmsbean.setName("l love you");
out.println(zmsbean.getName());
%>
---------取得属性值---直接打印出来------------
<jsp:getProperty name="zmsbean" property="name"/>
</body>
</html>
----------------------------------javarbean----------------------------
package beyond.step;
public class javabean1
{
private String name="zms";
public String getName()
{
return name;
}
public void setName(String outname)
{
this.name = outname;
}
}