• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:useBean

 
Prannav Santhosh
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


I have bean class "Person" (defined as abstract) with the following properties
name

I have another bean class "Employee" extends the "Person" bean class , with the following properties
empID


Question (1) -> I have a servlet with the following code


Person p = new Employee();
p.setName("Prannav");
request.setAttribute("emp", p);
System.out.println("Before dispatching the request");
RequestDispatcher reqDisp = request.getRequestDispatcher("/test.jsp");
reqDisp.forward(request, response);

In the test.jsp , i have the following code

****************************************************************************
<jsp:useBean id="emp" type="com.Employee" scope="request">
<jsp:setProperty name="emp" property="name" value="PRANNAJ2EE"/>
</jsp:useBean>

Attribute name <jsp:getProperty name="emp" property="name"/>

****************************************************************************

When i run the above code i see the following output ,

Attribute name "PRANNAJ2EE". I get the same out if i define the type="com.Person" in the test.jsp

Can some one explain me why i am geting this output ?

thanks for your help !!

Regards
Prannav
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which server you are using?
It is giving output,

Attribute name Prannav

for Tomcat 5.0
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic