I have a class called "user" and am trying to access an array of these guys that is set up in a servlet with EL, and it appears that EL thinks that it is a string.
Here is the servlet code where it is set up:
The user list (with a length of one for testing purposes) seems OK in the servlet.
The getters user.getUserKey(), user.getUserID(), etc. are all defined, and set up as per the following example:
and here is the point in the JSP where I'm trying to access it (the <option> tag and it's body):
The error I get is:
It *seems* that tomcat thinks it's a string, instead of a user. This is the first time I've use EL or JSTL extensively, but thought type coercion would fix it.
There's a good chance I don't understand the difference. The syntax I was using was similar to the way one would access a bean, attribute or a name/value pair. The syntax suggested by Ben that worked was EL syntax. I suppose I must confess it is not clear to me when one uses one versus the other, why in this context the access is as an EL variable when I set it using HttpRequest.setAttribute().
The answer may also explain another problem I was just going to post. I don't have a clear understanding at all as to when the various variable go in and out of scope,and exactly how they're accessed under various circumstances.
Do not confuse the JSTL tags with the classic actions like <jsp:getProperty>. They have little in common.
You should have the JSTL Specification open on your desk. The descriptions of the JSTL action in that document are essential.
In
<c:forEach items="userlist" var="listOfUsers">
the items attribute is the string containing the characters u s e r l i s and t.
In
<c:forEach items="${userlist}" var="listOfUsers">
the EL ${} notation makes its content an EL expression; in this case one that references a scoped variable named userlist. [ September 22, 2006: Message edited by: Bear Bibeault ]
Right. I understand perfectly that "u" doesn't equal "you" and only use it under extreme circumstances (like trying to text message and drive at the same time;-). Those of us in the civilized world also capitalize and punctuate, so I actually strongly agree with the policy.
But when you need it, like you did, how do you get the message board to take it? Is there an escape sequence?