Forums Register Login

Clarification needed regarding jsp:getProperty

+Pie Number of slices to send: Send
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();
student.setName("abc");
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.

Regards,
Balaji
SCJP 1.4
+Pie Number of slices to send: Send
 

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".
+Pie Number of slices to send: Send
<jsp:getProperty name="student" property="name"/>
this line should be
<jsp:getProperty name="studentObj" property="name"/>
When I was younger I felt like a man trapped inside a woman’s body. Then I was born. My twin is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 808 times.
Similar Threads
usebean is not working with jsp
How type attribute in useBean be applied
jsp:getProperty
useBean, getProperty and typecasts
<jsp:useBean> standard action type and class confusion
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 22:13:29.