• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Now confused ......

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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."
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thank you for the reply.


Regards
V.Parsuvanath.
 
reply
    Bookmark Topic Watch Topic
  • New Topic