*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFSJ doubt :Pg:356 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFSJ doubt :Pg:356" Watch "HFSJ doubt :Pg:356" New topic
Author

HFSJ doubt :Pg:356

georgy jacob
Ranch Hand

Joined: Nov 23, 2005
Posts: 53
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

Joined: Dec 12, 2005
Posts: 11
jacob I think u r right.


Shit Happens...
georgy jacob
Ranch Hand

Joined: Nov 23, 2005
Posts: 53
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

Joined: Nov 15, 2004
Posts: 1026
Check the Errata section here

Page: 416


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
georgy jacob
Ranch Hand

Joined: Nov 23, 2005
Posts: 53
Thanks vishnu . The errata section u provided was really useful
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: HFSJ doubt :Pg:356
 
Similar Threads
Whats the error???
Is this an error in HFSJ ??
Bean related exercise question
HFSJ Question Pg No 356
jsp:useBean related doubt