Reputation: 7386
i'm trying to get a property value from a bean object inside jsp using standard actions,the initial html form go to a servlet which sets a value inside the desired property,sets the attribute inside the request object and then forwards it to the jsp page, the jsp gets the value from the property by using standard actions but it gets null!:
the bean object:
public class dog {
private String bread;
public String getBread() {
return bread;
}
public void setBread(String bread) {
this.bread = bread;
}
}
the servlet:
dog d=new dog();
d.setBread("Kizer");
request.setAttribute("bread", d);
RequestDispatcher view=request.getRequestDispatcher("index.jsp");
view.forward(request, response);
the JSP (index):
< id="person" class="com.example.model.dog" scope="request" />
Person created by servlet: <jsp:getProperty name="person" property="bread" />
why it returns null ?
Upvotes: 0
Views: 8238
Reputation: 4474
In your JSP use
<jsp:useBean id="bread" class="com.example.model.dog" scope="request" />
<jsp:getProperty name="bread" property="bread" />
Upvotes: 1