File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Confusion, HFSJ Page 385 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Confusion, HFSJ Page 385" Watch "Confusion, HFSJ Page 385" New topic

Confusion, HFSJ Page 385

Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1710

I am not able to grasp the following line of HFSJ page 385:
Think about the scenario, if you have a name that's not in quotes in brackets[], that means it MUST adhere to Jana naming rules, right? Here, we're OK, because person is perfectly legal Java variable name. But that's because somewhere, someone said


But the attribute name is a String.

Strings dont follpow Java variable name rules.

Please help me!


swarna dasa
Ranch Hand

Joined: Mar 15, 2007
Posts: 108
String could be "1234"

so you could say request.setAttibute("1234",p);

but with dot operator, 1234 is not a valid java identifier, so you cant say
pageContext.request.1234 //wrong

can say
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1710
Very nice description Swarna!

Got it.

I agree. Here's the link:
subject: Confusion, HFSJ Page 385
It's not a secret anymore!