I almost simultaneously received all your three's reply. Thanks your all. I shall remember that EL only validates inside of the tag space.
Good night. 9/10/2002 6:12:21 PM, Hans Bergsten <[EMAIL PROTECTED]> wrote: >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 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. > >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:choose> > <c:when test="${empty prov.photoPaths}"> > <IMG SRC="<c:url value="/images/no_photo.gif" />" > NAME="No Photo Available" ALIGN=BOTTOM BORDER=0> > </c:when> > <c:otherwise> > <IMG SRC="<c:out value="${prov.photoPaths[0]}" />" > NAME="Photo" ALIGN=BOTTOM BORDER=0> > </c:otherwise> > </c:choose> > >Note the use of <c:url> for the case when no path is provided; it adds >the context path automatically for you. > >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]>