Assigning JSP variable to the output of tags


It is often useful to capture the output of an X-Application tag and assign it to a JSP variable (eg. for further manipulation, validation, etc).

Unfortunately this is not trivial because the output of the tag is written directly to the page.

ie. we cannot say
String zip = <bdm:display select=“/Address/Zip”>

Here is a custom tag that allows us to do this using the following syntax:

<test:SetVariable name=“zip” create=“true”>
<bdm:display select=“/Address/Zip”>

Value of zip = <%= zip %>

I’ve attached a sample web application in addition to the .tld and .jar files.

Hope this will be of some use to anyone looking for this kind of functionality.

Best Regards,
Puny Sen (7.87 KB)

I should have known it before rewriting many pages with JAVA API…
Anyway I think it’s really useful…