permaculture playing cards*
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
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "jsp:useBean" Watch "jsp:useBean" New topic
Author

jsp:useBean

Prannav Santhosh
Greenhorn

Joined: May 09, 2009
Posts: 29
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

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

Attribute name Prannav

for Tomcat 5.0


Thanks,
Shailesh
 
wood burning stoves
 
subject: jsp:useBean
 
Similar Threads
Whats the error???
Doubt with <jsp:useBean> having only type no class attribute
useBean with only type attribute(please help)
jsp:useBean type is not working?
useBean, getProperty and typecasts