Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

bean related standard actions HFSJ pages 356 and 416

 
Sean Duncan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've come across a confusing exercise in HFSJ on page 356.

Look at this standart action:
<jsp:useBean id="person" type="foo.Employee">
<jsp:setProperty name="person" property="name" value="Fred"/>
</jsp:useBean>
Name is: <jsp:getProperty name="person" property="name"/>


(3) What happens if the servlet looks like:
foo.Employee p = new foo.Employee();
p.setName("Evan");
request.setAttribute("person", p);


The answer on page 416 says

This works fine and prints out "Evan". Remember, the code INSIDE the body of <jsp:useBean> will Never run, since we specified a type without a class.


This seems wrong to me because the useBean tag is looking for the bean in "page" scope and the attribute is set in request scope. It isn't going to find it and won't be able to create it via the tag body since only the type attribute is specified. It looks like this will be an error at runtime.

If anyone can either back me up on this or tell me where I went wrong I would really appreciate your time.

-Sean
 
Sanjay pts
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its error in book.I think this link will help you to find out the problem.


http://www.oreilly.com/catalog/headservletsjsp/errata/headservletsjsp.confirmed

thanx
sanjay
 
Sean Duncan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sanjay
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic