• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

page 356 HSFJ

 
abhishek tiwari
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,
i have the following doubt from HSFJ(Page number 356):-

servlet code

foo.Employee p = new foo.Employee();
p.setName("Evan");
request.setAttribute("person",p);

standard 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"/>

Output is Name is Evan

the person attribute is stored in the request scope in the servlet code whereas the standard actions looks for it in the default scope i.e the page scope.so don't you think we should have a compile time error.

kindly solve my problem at the earliest

thanks in anticipation
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct. That attribute shoild not be available to the JSP, since it's using the default scope of "page". It's probably a typo in the book.
 
Edmund Yong
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is an error. Check the errata.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic