Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Now confused ......

 
VP Jain
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Regarding "BE the Container " in pg 356 of Head First Book.

which states that

What will happens if the servlet code looks like

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

and the Standard action in JSP is

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


and the answer provided in pg 416 is

Ans : 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


But when i incorporated the same logic in Tomcat version 5.0

I get a java.lang.InstantiationException:beann person not found ...

But when i change the action tag as

<jsp:useBean id="person" class="foo.Employee" >

it's working fine.

So is the answer in Pg 416 is wrong or am i missing out something.


Please help


Regards
V.Parsuvanath.
 
Ture Hefner
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi V.,
Don't worry. You are understanding it correctly. The answer in the book is wrong. Check out the errata at

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

"[416] Be the Container Answers;
The third example will not work for the same reason that the first example doesn't work, because the attribute is at Request Scope, and the default scope is Page scope. The handwritten comment for bullet #3 should be the same as for bullet #1."
 
Pabak Nanda
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check the errata page for the book.web page
 
VP Jain
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thank you for the reply.


Regards
V.Parsuvanath.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic