About Question com.enthuware.ets.scwcd.v5.2.56 :

Moderator: admin

Post Reply
marcelomnc
Posts: 5
Joined: Mon Jun 10, 2013 9:44 pm
Contact:

About Question com.enthuware.ets.scwcd.v5.2.56 :

Post by marcelomnc »

The system marks this answer as correct:
The EL code within the body of the tag may refer to the iteration variable but scripting code cannot.
With the following note:
For example, <%=dept.getName()%> is invalid here:

<c:forEach var="dept" items="${departments}">
<c:out value="${dept.name}"/><br><%=dept.getName()%>
</c:forEach>
But I guess its WRONG, because the scripting code can access the iteration variables as follows:

Code: Select all

<c:forEach var="str" items="${arr}" varStatus="status">
	<c:out value="${str}"/><br>
	<c:out value="${status.count}"/><br>
        Now with scriptlet:<br>
	<%=pageContext.getAttribute("status")%><br>
	<%=((String)pageContext.getAttribute("str")).toUpperCase()%><br>
</c:forEach>
I have tested this code and obtained correct output as well. So i guess this can be misleading.

Am I right with this?

ArsenyKo
Posts: 11
Joined: Sun Apr 07, 2013 10:10 am
Contact:

Re: About Question com.enthuware.ets.scwcd.v5.2.56 :

Post by ArsenyKo »

In that way you are accessing "context attributes" but not "variables". That was my train of thoughts when I met the question.

admin
Site Admin
Posts: 10385
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question com.enthuware.ets.scwcd.v5.2.56 :

Post by admin »

You are not really accessing the scripting variable. You are accessing the object that stored in the context under the same name.

HTH,
Paul.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests