Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

HFSJ doubt :Pg:356

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This qn is taken from HFSJ book Pg:356

Consider that employee is a concrete class which implements abstract class Person


<jsp:useBean id="person" type="foo.employee">
<jsp:setProperty name="person" property ="name" value="Fred"/>
</jsp:useBean>


Imagine the servlet forwards the request to the above Jsp. Fig out what the Jsp would do for each version of the servlets.



what happens if the servlet code looks like

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

ans: Fails at request time as the person attribute is stored at request scope while the jsp uses page scope.


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

works fine

But in servlet code 2) as wel the attrbute is stored at request scope.. I am not getting this point. Shouldnt a compiler error be thrown again. Please help
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jacob I think u r right.
 
georgy jacob
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But i dont think an error will be there in the book.. I guess we understood the concept a little differently.. By the way i meant that a error will occur during request(run time) and it will not be a compiler error
 
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the Errata section here

Page: 416
 
georgy jacob
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks vishnu . The errata section u provided was really useful
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic