tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Cooper" <martin.coo...@tumbleweed.com>
Subject RE: How to access an element of array without using the iteration tag
Date Wed, 11 Sep 2002 01:00:58 GMT
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:vernonw@gatewaytech.com]
> 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 <hans@gefionsoftware.com> 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		hans@gefionsoftware.com
> >Gefion Software		http://www.gefionsoftware.com
> >JavaServer Pages	http://TheJSPBook.com
> >
> >
> >--
> >To unsubscribe, e-mail:   
> <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
> >For additional commands, e-mail: 
> <mailto:taglibs-user-help@jakarta.apache.org>
> >
> >
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:taglibs-user-help@jakarta.apache.org>
> 
> 


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message