File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Android Security Essentials Live Lessons this week in the Android 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

It is sorta covered in the JavaRanch Style Guide.
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