| Author |
Use of [] in EL - Doubt
|
Manikandan Jayaraman
Ranch Hand
Joined: Sep 15, 2004
Posts: 225
|
|
I was trying to validate the below statement through an example: If there is no quotes against the variable inside [], then container tries to find an attribute with that name and get its value and use that value as the map�s key or the bean�s property. My servlet code had the following line: req.setAttribute("test1","value1"); req.getRequestDispatcher("/jsp/ELDemoJsp.jsp").forward(req,res); My JSP tried the following: requestScope.mani -> ${requestScope.mani} <br> requestScope["mani"] -> ${requestScope["mani"]}<br> requestScope[mani] -> ${requestScope[mani]}<br> My Output showed: requestScope.test1 -> value1 requestScope["test1"] -> value1 requestScope[test1] -> I was not able to get "value1" for the third EL ... why? Is this rule applicable only for Maps/Lists and Arrays ?
|
Regards,<br />Mani<br />SCJP 1.4 (95%)<br />SCWCD 1.4 (94%)
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
(I think you misstypes mani for test1) requestScope[test1] will look for "value1" in the request. try :
|
[My Blog]
All roads lead to JavaRanch
|
 |
Manikandan Jayaraman
Ranch Hand
Joined: Sep 15, 2004
Posts: 225
|
|
Hey Yes! Sorry about that Mistake! And yes! What you said worked ... Was a bit confused and now it is clear! Thanks!
|
 |
Manikandan Jayaraman
Ranch Hand
Joined: Sep 15, 2004
Posts: 225
|
|
Hey Yes! Sorry about that Mistake! And yes! What you said worked ... Was a bit confused and now it is clear! Thanks!
|
 |
 |
|
|
subject: Use of [] in EL - Doubt
|
|
|