On Thu, 10 Feb 2005 23:09:51 -0500, Erik Weber <[EMAIL PROTECTED]> wrote:
> Sorry, I was using the html-el tag, not the html tag:
> 
> <html-el:img src="${somePath}/images/foo.jpg"/>
> 
> I think you should be able to do what you want without the el tags if
> you are using JSP 2.0, but to be honest, someone else needs to jump in
> and bail me out here on that. I think it's a configuration problem. (web
> app 2.3 v 2.4 or something?)

You are definitely on the right track.

If you are using a Servlet 2.4/JSP 2.0 container (such as Tomcat 5.x),
you can enable support for EL expressions globally in your pages (even
in template text -- it doesn't have to be in a custom tag attribute). 
This requires telling the container that you are a Servlet 2.4 webapp,
by including the following as the root element:

    <web-app       xmlns="http://java.sun.com/xml/ns/j2ee";
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                     http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
            version="2.4">

instead of the DOCTYPE declaration used on previous versions.  Doing
this makes the struts-el library totally superfluous -- EL expressions
work as expected on all the standard Struts tags.

This capability lets you do some cute things, even without a lot of
custom tags.  Consider the following example (using JSTL tags) where
"customers" is an attribute that contains an array (or List) of
Customer beans.

    <table>
        <tr>
            <th>Id</th>
            <th>Name</th>
        </tr>
        <c:forEach items="${customers}" var="customer">
            <tr>
                <td>${customer.id}</td>
                <td>${customer.name}</td>
            </tr>
        </c:forEach>
    </table>

(Note that you can get the same sort of filtering that <bean:write>
does for you, to avoid cross site scripting attacks, by using things
like "<c:out value='${customer.id}'/>" instead of "${customer.id}" if
you need it.)

(If you want to do *input* into a table like this, consider using
JavaServer Faces (JSF) components like <h:dataTable> instead ... it
manages all the hard parts for you.)

> 
> Erik
> 

Craig

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

Reply via email to