For Programmers: Free Programming Magazines  


Home > Archive > Java Help > February 2005 > How to export variable from an JSP 2.0 tag file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to export variable from an JSP 2.0 tag file
Treespace

2005-02-28, 3:59 am

Using JSP 2.0 XML tag file that contains a scriptlet. The scriptlet set
a page attribute of type Bar. I can now use "bar" in EL expressions on
page that uses this tag. QUESTION: do I have to pass in the pageContext
as an attribute to do this?

<%@ tag body-content="empty" %>
....

<jsp:directive.attribute name="foo" required="true"
type="com.acme.Foo"/>
<jsp:directive.attribute name="ctx" required="true"
type="javax.servlet.jsp.PageContext"/>

<jsp:scriptlet>
ctx.setAttribute("bar", foo.getBar());
</jsp:scriptlet>


Side question: after setting the attribute, "bar" cannot be accessed
within the tag itself, e.g., ${bar.status} complains it cannot find
bar. It's as though it is evaluating the EL before the scriplet runs.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com