Forums Register Login

jsp:useBean tag question

+Pie Number of slices to send: Send
there is an example in Head First(1.4 ver book) which mentions pg 356 (chap 8-be a container)
in 3rd option that
request.setAttribute("person",p) will enable
<jsp:useBean id="person" type="foo.Employee"/>
<jsp:getProperty name="person" property="name"/>

this to give correctly the name set even though as we know that if

scope

is not mentioned it defaults to page. here it should default to page and since the attribute

person

is set in request scope it should not be able to find the bean.

please help me understand if there is flaw in my understanding!!??
+Pie Number of slices to send: Send
If scope is not specified then it is the page scope. Since there is no attribute in with the name person in the page scope the container will try to create one in the page scope but since we didn't provide the class in this case the useBean will raise an exception.

for this to work you either need to specify the scope in useBean or the class.
+Pie Number of slices to send: Send
yeah i too agree on the same thing Musab Al-Rawi.
But my point is that the same concept has been very much emphasized in the first scenario on the same(pls refer the question at top) page of HFJS 1.4, that if the bean person is not there in the request scope then it would fail at run time.

even then how could this mistake be done in the book ...?

thanks
Bhupen
[ May 27, 2008: Message edited by: Bhupendra Khabrani ]
+Pie Number of slices to send: Send
have you checked in errata regarding this ?

http://www.oreilly.com/catalog/headservletsjsp/errata/headservletsjsp.confirmed
[ May 27, 2008: Message edited by: Garla Ravi ]
+Pie Number of slices to send: Send
Thanks Ravi,
on closely looking i could find the same in the errata.

thanks for help guys.
Bhupen
Why is the word "abbreviation" so long? And this ad is so short?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 573 times.
Similar Threads
Head First Servlets and JSP:SCWCD Question
jsp:useBean and jsp:setProperty question
getProperty question
page 356 HSFJ
Bean standard action doubt
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:45:05.