tags:

views:

226

answers:

1

lets suppose we have a sample.jsp page:

<%@ taglib prefix="custom" tagdir="/WEB-INF/tags" %>
...
<custom:do var="foo"/>
...

is it possible to generate variable with name 'foo' in do.tag which will be visible in our sample.jsp page? page scope variable?

A: 

so, yes, it's possible ;)

<%@ attribute name="var" required="true" rtexprvalue="false" %>
<%@ variable name-from-attribute="var" alias="mirror" scope="AT_END" %>

<c:set var="mirror" value="works"/>

but this attribute cannot be optional :( if you want to make some conditional assignment (for example: if var exists - assign something to it, if not - show something) it's not possible

details: http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPTags5.html#wp89909