You have several problems in your code:
java.util.Arrays.asList(list)
won't transform an Enumeration into a List. It will create a List containing a single element: the enumeration. You should use Collections.list() to do that.
- There is no reason to transform a List into a Vector. Vector (like Enumeration, by the way) is an old class that shouldn't be used anymore, and List has all you need.
- You should use generic types and not raw types. It would save youmany unnecessary casts
- This code shouldn't be in a JSP in the first place, but in a servlet or controller
- You're trying to access
aString
from outside the loop, but aString is defined inside the loop
- The JSP EL doesn't access local variables. It accesses page, request, session or application attributes. If you want it to access a local variable, you need to store this variable in a page scope attribute.
- I guess you want to display every string in the enumeration. In that case, you should use the
c:forEach
tag, and not a while loop.
So, the code could be written as such:
<% RFQProdAccessBean ab= new RFQProdAccessBean();
Enumeration<String> enumeration = (Enumeration<String>) ab.findByRFQId(13001L);
pageContext.setAttribute("list", Collections.list(enumeration));
%>
<c:forEach var="element" items="${list}">
<c:out value="${element}"/>
</c:forEach>
But, I repeat, the Java code should be out of the JSP, and should store the list into a request attribute. The forEach loop would stay unchanged.