Hi,
I really don't understand why the following code in JSP is running fine, but as described in Head first book, it will show compile time error.
<html><body>
<jsp:useBean id="person" type="foo.Person" scope="request">
<jsp:setProperty name="person" property="name" value="Fred"/>
</jsp:useBean>
<jsp:getProperty name="person" property="name"/>
</body></html>
The code of Person class is:
package foo;
public class Person extends foo.Person1
{
private String s;
public void setEmpID(String s)
{
this.s=s;
}
public String getEmpID()
{
return s;
}
}
and the code to instantiate foo.Person in servlet class and setting it as an attribute "Person" in request scope is:
Person1 p=new Person();
p.setName("Greenhorn");
request.setAttribute("person",p);
and the code of Person1 bean class is:
package foo;
public abstract class Person1
{
private String s;
public void setName(String s)
{
this.s=s;
}
public String getName()
{
return s;
}
}
Why it is working? why it is not showing any error? Is the book wrong?
Thanks in advance for any suggestion.