You have two problems here. First, JSP scripting variables are not available
from the JSTL expression language. Second, you can't (yet) use JSTL
expressions outside JSTL tag attributes.

You'll need to set an attribute, like this:

<% pageContext.setAttribute("prov", prov); %>

and then access it like this:

<img src='<c:out value="${pageContext.prov.photoPaths[0]}"/>'

--
Martin Cooper


> -----Original Message-----
> From: Vernon Wu [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 10, 2002 5:51 PM
> To: Tag Libraries Users List
> Subject: Re: How to access an element of array without using the
> iteration tag
> 
> 
> 
> 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 Available" 
> ALIGN=BOTTOM BORDER=0>
>               <% } else {  %> 
>                       <IMG 
> SRC="<%=(prov.getPhotoPaths())[0]%>" NAME="Photo" 
> ALIGN=BOTTOM BORDER=0>
>               <% } %>
> 
> <IMG SRC="${prov.photoPaths[0]}"> doesn't seem to work.
> 
> 
> 
> 
> 9/10/2002 5:01:53 PM, Hans Bergsten <[EMAIL PROTECTED]> wrote:
> 
> >Vernon Wu wrote:
> >> I need to access the first element of array using JSTL. 
> After a few of trial and error, I don't success without using the 
> >> iteration tag. I don't image that is a difficult one, but 
> just don't know how.
> >> 
> >> Thanks for your cue.
> >
> >Use an EL expression like this: ${myArray[0]}
> >
> >Hans
> >-- 
> >Hans Bergsten                [EMAIL PROTECTED]
> >Gefion Software              http://www.gefionsoftware.com
> >JavaServer Pages     http://TheJSPBook.com
> >
> >
> >--
> >To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> >For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> >
> >
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 
> 


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to