• Post Reply Bookmark Topic Watch Topic
  • New Topic

Expression Language  RSS feed

 
MaheshS Kumbhar
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per the rule, anything inside [] which is not in quotes must satisfy java naming rules. Then how does following code work even though thing inside [] is not in quotes and which doesn't comply to java naming rules?



 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know where you read about the Java naming rules in retrieving the array or list values in bracket operator. The EL either takes an index OR map key value, if its not quoted.
 
MaheshS Kumbhar
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sagar
What I read from "Head first Servlets and JSP" is that thing inside [] could be in quotes or without quotes but if its not in quotes then it must adhere to Java naming rules.
And if this is the rule then the EL expression in above code shouldn't work.

Correct me if I am wrong.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MaheshS Kumbhar wrote:What I read from "Head first Servlets and JSP" is that thing inside [] could be in quotes or without quotes but if its not in quotes then it must adhere to Java naming rules.
And if this is the rule then the EL expression in above code shouldn't work.

I just flip some pages of my HFSJ copy and found that you took the opposite meaning right, means if its in "quotes", then it must adhere to Java naming policy, if the right hand side is map or bean.

Reread chapter 8, line no: 370
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're just using normal array notation--why wouldn't you be able to access an array index by using a number?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66152
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "rules" you are stating apply only when the base is a map or bean. If the base is a list, the subscript must be numeric.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66152
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sagar Rohankar wrote:... means if its in "quotes", then it must adhere to Java naming policy.
Nonsense. What's in the quotes can be any string.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!