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 Clarification needed regarding jsp:getProperty 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 "Clarification needed regarding jsp:getProperty" Watch "Clarification needed regarding jsp:getProperty" New topic

Clarification needed regarding jsp:getProperty

Balaji Madhavan

Joined: Sep 05, 2007
Posts: 3
I am planning to give my SCWCD exam by 29 sep. I was preparing some mock test questions and encoutered this question.

A JSP page uses a Java bean as shown below:
<%@page import="beans.Student"%>
Student student = new Student();
session.setAttribute("studentObj", student);

The question is about using standard actions to print the name property of Student object.

The answer is given as
<jsp:useBean id="studentObj" class="beans.Student" scope="session"/>
<jsp:getProperty name="student" property="name"/>

As per the spec, the value of the id attribute used in the jsp:useBean should be used in the name attribute of jsp:getProperty.

But I notice the "student" [The object declared in the java program] is used instead of "studentObj" from jsp:useBean tag.

I am in need of a clarification regarding the usage of "student" instead of "studentObj" in this case.

SCJP 1.4
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

I am in need of a clarification regarding the usage of "student" instead of "studentObj" in this case.

It's probably an error. It should be "studentObj".

[My Blog]
All roads lead to JavaRanch
paritosh ranjan
Ranch Hand

Joined: Aug 24, 2007
Posts: 62
<jsp:getProperty name="student" property="name"/>
this line should be
<jsp:getProperty name="studentObj" property="name"/>
I agree. Here's the link:
subject: Clarification needed regarding jsp:getProperty
It's not a secret anymore!