You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by William R Briggs <wr...@us.ibm.com> on 2003/12/04 16:46:50 UTC
New to JSTL
I've done a small amount of JSP and servlet programming in the past, but
most of my java programming has not been web-based. I am currently trying
to write a small JSP web application in order to learn more about it.
In my app, I have a bean that performs some database access via JDBC. The
bean has a method that returns an ArrayList of customer names, and I want
to list these names in a pull-down. Prior to using JSTL, I would have
done this:
<select name="custName">
<%
ArrayList custNames = foundryCustomerQuery.getCustomerList();
for(int i = 0; i < custNames.size(); i++) {
<option selected="selected"> <%= custNames.get(i) %> </option><%
}
%>
</select>
This works fine, just as I expect it would.
Now, trying to do this with JSTL:
<c:forEach var="customer"
items="${foundryCustomerQuery.getCustomerList()}">
<option><c:out value="${customer}" /></option>
</c:forEach>
I receive the error "The function getCustomerList must be used with a
prefix when a default namespace is not specified." I'm stumped, as my
knowledge of JSTL is not great enough to figure out what is going on here.
I have also tried mixing a scriptlet with the JSTL tags (not something I
want to do), like so:
<%
ArrayList custNames = foundryCustomerQuery.getCustomerList();
%>
<c:forEach var="customer" items="${custNames}">
<option><c:out value="${customer}" /></option>
</c:forEach>
This produces no errors, but the forEach loop provides no output.
Any help would be much appreciated!
Thanks,
Will
William Briggs
Software Engineer
IBM Foundry e-Business and Technical Operations
T/L: 446-4051
(802) 769-4051
wrbriggs@us.ibm.com