*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jsp:useBean doubt? 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 "jsp:useBean doubt?" Watch "jsp:useBean doubt?" New topic
Author

jsp:useBean doubt?

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Guys,

On page 416 of HFSJ, it says that the first option fails to compile, but the third option compiles fine. For the first one, I can understand the reason but why for the 3rd one, it works fine?? Any help on this would be of real help to me to understand it better.

Thanks in advance!


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
VijayKumar Sivagnanam
Greenhorn

Joined: Dec 25, 2006
Posts: 26
can you quote the question please


SCJP 1.2 <br />SCWCD (94%)<br />SCBCD (preparing)
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
check Head First Servlets and Jsp Errata
You will get correct answer.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Yes,

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

What happens if the servlet code looks like:

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

The above one fails at request time, but whereas

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

This works fine and prints Evan! How? We are only specifying the type? aren't we??

Also, if I comment out all the p.setName("Evan") in all the 2 cases above, then the o/p will be Fred right??
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Gowher,

Where can I get the errata for the HFSJ? Please help!
Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
http://www.oreilly.com/catalog/headservletsjsp/errata/headservletsjsp.confirmed


Micheal John
SCJP 1.4 (86%), SCWCD 1.4 (86%), SCBCD 1.3 (85%), SCDJWS (Just Started...) - Satisfaction Lies in Our EFFORT, Not in the ATTAINMENT
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Thanks Michael.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp:useBean doubt?
 
Similar Threads
Another qstn for you all... Just to enforce the point..
very tricky
How can we share any information between two web application
wait() and notify() in K&B 5.0
How to set Session tracking cookie other than in weblogic.xml