Hi everyone,
I'm a newbie on Java EE and got a problem that I don't understand why it's happening. Here is my problem :
I can't access a JavaBean using <jsp:getProperty>
which is created in a scriptlet in the same page.It's throwing the below exception :
Attempted a bean operation on a null object.
Here is my bean and jsp page :
package com.webProject3.beans;
public class User implements java.io.Serializable {
private static final long serialVersionUID = 1209333714609490385L;
private int id;
private String lastName;
private String firstName;
public User(){
}
public void setId(int id) {
this.id = id;
}
public int getId() {
return id;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getLastName() {
return lastName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getFirstName() {
return firstName;
}
}
<body>
<%
com.webProject3.beans.User requestedUser = new com.webProject3.beans.User();
requestedUser.setFirstName("Peter");
requestedUser.setLastName("Petrelli");
%>
<p><jsp:getProperty name="requestedUser" property="firstName"></jsp:getProperty></p>
</body>