On 8/18/05, Murray Collingwood <[EMAIL PROTECTED]> wrote:
> Hello all
> 
> Has anybody successfully used Stuts tags and Custom tags together?
> 
> For example:
> Consider a custom tag with the following code:
>   out.println("<html:link action=\"Update.do\">" + entry[ix] + 
> "</html:link>");
> 

Your question doesn't really describe what you are illustrating ...
which appears to be that you want to dynamically create a *JSP* page,
then have the page compiled and executed, on every request.  You're
going to find that this solution is not practical, and that you should
take another approach.

When you first start a webapp, you notice the slight delay when you
access a JSP page the first time, so that it gets compiled?  Even if
you jumped through all the technical hoops to output a JSP file and
get it compiled (technically feasible), you're going to be imposing
that kind of overhead on *every* request, instead of just the first
request for that page.  Even if everything else in your app was
instantaneous, the response time of your app would be awful.

A far better approach for the particular case you are using here is to
use either an expression or some subordinate tag to calculate the
dynamic part of your output.  Assume for a moment that your Struts
action puts the "entry" array into request scope.  Now you can do
something like:

    <html:link action="Update.do">
        <c:out value="${entry[3]}"/>
    </html:link>

Of course, the reason you probably want to do this in the first place
is that you want to create a bunch of links ... so put the same sort
of structure inside a looping tag (renaming the request scope
attribute containing your array to be "entries" to be more readable):

    <c:forEach var="entry" items="entries">
        <html:link action="Update.do">
            <c:out value="$entry"/>
        </html:link>
    </c:forEach>

The <c:forEach> tag exposes the current element in the array as a page
scope attribute named by the "var" attribute, and you can therefore
reference the current element directly inside the loop.

Craig

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

Reply via email to