2

I wrote a simple jsp code that uses Bean class - BeanDemo. I am using NetBeans IDE and GlassFish Server 4.0. Now when I try to run the jsp file,I get the exception mentioned above. I looked for similar questions in StackOverflow but none of the answers seem to be solving my problem. Or I probably missed something. I am new to this,so please be kind :) Thank you!

1.beaneg.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
</head>
<body>
    <h1>Hello World!</h1>
    <jsp:useBean id="demo" class="beanpack.BeanDemo">
        <OL>
 <LI> 
  <I> ${demo.str} </I>
<LI> <jsp:setProperty name="demo" property="str"
                     value="This is New Message" />

        <I> <jsp:getProperty name="demo" property="str" /> </I>
  </OL>
  </jsp:useBean>
</body>
</html>

BeanDemo.java

 package beanpack;


public class BeanDemo {

private String str="Hello";

 public BeanDemo()
{

}
 public String getMessage()
{
    return str;
}
public void setMessage( String str)
{
    this.str=str;
}

}
4

1 回答 1

1

您需要将属性名称指定为message而不是str

<jsp:getProperty name="demo" property="message" >
于 2015-07-24T15:46:27.837 回答