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 Use of [] in EL - Doubt 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 "Use of [] in EL - Doubt" Watch "Use of [] in EL - Doubt" New topic
Author

Use of [] in EL - Doubt

Manikandan Jayaraman
Ranch Hand

Joined: Sep 15, 2004
Posts: 230
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: 14687
    
  16

(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: 230
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: 230
Hey Yes! Sorry about that Mistake!

And yes! What you said worked ... Was a bit confused and now it is clear!

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Use of [] in EL - Doubt
 
Similar Threads
Can't inlculde files from a parent directory in new tomcat
requestScope Querry
Arithmetic value of "" in EL expressions
EL
Help on Tag Files - attribute directive.