File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ doubt :Pg:356

 
georgy jacob
Ranch Hand
Posts: 53
  • 0
  • 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
 
Indunil Dasanayaka
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jacob I think u r right.
 
georgy jacob
Ranch Hand
Posts: 53
  • 0
  • 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
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the Errata section here

Page: 416
 
georgy jacob
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks vishnu . The errata section u provided was really useful
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic