tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Turner <j...@socialchange.net.au>
Subject Re: dynamic attributes
Date Fri, 24 Nov 2000 04:49:34 GMT
On Thu, 23 Nov 2000, Hans Bergsten wrote:

> Jeff Turner wrote:
> > 
> > Hi,
> > 
> > Is there any way to dynamically create attributes for JSP taglib elements?
> > 
> > Eg, how would I do the following:
> > 
> > <util:include
> > url="/servlet/MyServlet?q=<%request.getParameter("param");%>" />
> > 
> > ? I'd like Tomcat to first evaluate <% request.getParameter("param"); %>,
> > and then feed that to <util:include url="..."/>.
> > 
> > Cocoon (http://xml.apache.org/cocoon) handles the above as follows:
> > 
> > <util:include>
> >   <util:url>
> >   /servlet/MyServlet?q=<xsp:expr>request.getParameter("param")</xsp:expr>
> >   </util:url>
> > </util:include>
> > 
> > So every attribute also has an equivalent "nested element" form. That's
> > possible because Cocoon XSP taglibs are written in XSLT, whereas JSP has a
> > more rigid API-based model.
> > 
> > Is any general way of doing this?
> 
> If you declare your attribute as a request-time attribute in the TLD,
> you can assign it a value this way:
> 
>   <util:include
>     url="<% "/servlet/MyServlet?q=" + request.getParameter("param") %>" />
> 
> See the JSP specification for details.

Great :) Sorry, I didn't look hard enough through the spec. For others,
it's section 2.12.1, "Request Time Attribute Values". Basically, in your
TLD's attribute tag, you put <rtexprvalue>true</rtexprvalue>.

The spec is pretty strict. I finally got it to work as follows:

<%
String qterm = "/servlet/MyServlet?query="+term;
%>
<util:include url="<%=qterm %>"/>


--Jeff

> 
> Hans
> -- 
> Hans Bergsten		hans@gefionsoftware.com
> Gefion Software		http://www.gefionsoftware.com
> 


Mime
View raw message