This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jsp:useBean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "jsp:useBean" Watch "jsp:useBean" New topic


Prannav Santhosh

Joined: May 09, 2009
Posts: 29

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

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

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

Person p = new Employee();
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"/>

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 !!

Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
Which server you are using?
It is giving output,

Attribute name Prannav

for Tomcat 5.0

I agree. Here's the link:
subject: jsp:useBean
It's not a secret anymore!