Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJWCD
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Paul Clapham
Tim Cooke
Devaka Cooray
Sheriffs:
Liutauras Vilda
paul wheaton
Rob Spoor
Saloon Keepers:
Tim Moores
Stephan van Hulst
Tim Holloway
Piet Souris
Mikalai Zaikin
Bartenders:
Carey Brown
Roland Mueller
Forum:
Web Component Certification (OCEJWCD)
EL Mystery
khaled Jamal
Ranch Hand
Posts: 64
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi
Suppose we have a Person class like this one :
public class Person { private int id; private String name; public Person(int id, String name) { this.id = id; this.name = name; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String toString() { return String.format("%d, %s", id, name); } }
This is a part of code from a
servlet
:
Person p1, p2; p1 = new Person(1, "A"); p2 = new Person(2,"B"); java.util.List l = new ArrayList() ; l.add(p1);l.add(p2); request.setAttribute("list", l);
which dispatch to this
JSP
:
<c:forEach var="person" items='${list}'> <option value='${person.id}'>${person.name}</option> </c:forEach>
I want to know please how the container know the type of objects within the list to cast them in order to be able to access the id and name
Thanks
SCJP 6, SCBCD 5, SCWCD 5
Bear Bibeault
Sheriff
Posts: 67750
173
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
reflection
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
It means our mission is in jeapordy! Quick, read this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Accessing private variables directly from outside the class
JSTL c:forEach tag iteration variable
XMLEncoder - Stackoverflowerror - overriding equals
Sort Arraylist by passing runtime parameter
Comparator
More...