This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes No.10 note in Scwcd Hints is wrong? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "No.10 note in Scwcd Hints is wrong? " Watch "No.10 note in Scwcd Hints is wrong? " New topic
Author

No.10 note in Scwcd Hints is wrong?

Chrix Wu
Ranch Hand

Joined: Nov 15, 2009
Posts: 121
I read this on Scwcd Hints

10) ${"Not a Number"+ 3.0}. You will get a javax.servlet.jsp.el.ELException, complaining that Not a Number; cannot be converted to a java.lang.Double value. This example also goes to show that the addition operator in EL -unlike Java- is not overloaded to handle string concatenation. There's no operator overloading or string concatenation in EL.


but i also read this on head first book at page 428 mock question 6

${list["listIdx" + 1]} , ("listIdx" + 1) becomes a String ~


I am confused now...

anyone got any ideas?


** SCJP 5.0 84% **
** SCWCD 1.5 76% **
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

${list["listIdx" + 1]} , ("listIdx" + 1) becomes a String

I don't think it will. "listIdx" + 1 should be evaluated as an Integer, thus an error occurs.


[My Blog]
All roads lead to JavaRanch
Niteen Patil
Ranch Hand

Joined: Oct 27, 2009
Posts: 45
consider,
${list['listIdx'+1]}

here, 'listIdx' is a string in ['listIdx'+1]. EL will try to coerce 'listIdx' to a long which is not possible.

The character inside the quotes should be a digit [0-9] .
i.e,
${list['1'+1]} would be converted to ${list[2]}

Thanks,
Nitin.
Chrix Wu
Ranch Hand

Joined: Nov 15, 2009
Posts: 121
So what the HFSJ book said is incorrect?
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

There are many mistakes. Have a look on errata.


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Chrix Wu
Ranch Hand

Joined: Nov 15, 2009
Posts: 121
Thanks guys
 
 
subject: No.10 note in Scwcd Hints is wrong?
 
Similar Threads
using [] operator with an array
Question on EL
Hints for SCWCD
String concatenation in EL?
EL doubts about no quotes, single and double