tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <>
Subject Re: How to access an element of array without using the iteration tag
Date Wed, 11 Sep 2002 01:12:21 GMT
Vernon Wu wrote:
> Thanks Hans for your quick response. 
> In fact, I didn't phrase my question right. The data is a path of an image. The expression
doesn't work in the situation. I 
> have to use the script as the followings:
> 	<% if(prov.getPhotoPaths() == null) { %>
> 		<IMG SRC="<%=request.getContextPath()%>/images/no_photo.gif" NAME="No Photo
>       	<% } else {  %> 
>       		<IMG SRC="<%=(prov.getPhotoPaths())[0]%>" NAME="Photo" ALIGN=BOTTOM
>       	<% } %>
> <IMG SRC="${prov.photoPaths[0]}"> doesn't seem to work.

That's because you're using Java code in scriptlets, not JSTL and the EL
as you asked about. With JSTL and EL, something like this should work:

     <c:when test="${empty prov.photoPaths}">
       <IMG SRC="<c:url value="/images/no_photo.gif" />"
         NAME="No Photo Available" ALIGN=BOTTOM BORDER=0>
       <IMG SRC="<c:out value="${prov.photoPaths[0]}" />"
         NAME="Photo" ALIGN=BOTTOM BORDER=0>

Note the use of <c:url> for the case when no path is provided; it adds
the context path automatically for you.

Hans Bergsten
Gefion Software
JavaServer Pages

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message