Well, I can see several things here. First of all, it's important for
us to know what container and version you're using. From the error you
got from the JSTL test case, I'm guessing you're using one of the
revisions of Tomcat 5.
You talk about a "bean" that does some JDBC work. That certainly can
work, but it sends up a red flag for me. It's best to have bean classes
that are simple containers, and business logic in other classes which
populate those beans.
In the JSTL, you work with beans and their properties. In JSP 2.0, you
have some limited ability to call functions, but I wouldn't focus on
that too much.
If you have a bean that has a "getCustomerList()" method, this
represents the "customerList" property, so you would reference this in
the EL with "${foundryCustomer.customerList}".
Your attempt to mix scriptlets with the JSTL doesn't work because the EL
only reads "page-scoped attributes", not scriptlet variables.
If you haven't read the JSTL specification, read it.
> -----Original Message-----
> From: William R Briggs [mailto:[EMAIL PROTECTED]
>
> 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.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]