How to export variable from an JSP 2.0 tag file

From: Treespace (rmacpherson_at_verilet.com)
Date: 02/28/05


Date: 27 Feb 2005 17:59:35 -0800

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.



Relevant Pages

  • Re: tootip or microhelp for menu items
    ... I sort of find a way to make the tag value appear in a status bar but it is ... For each submenu time I have an event handler for select.. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How do I clear without a gap in FireFox?
    ... I was creating a blog for a friend gone to China. ... I found that if the clear:both css was used on the comment bar, ... of the gap either. ... The problem is that the containing element (in my case a tag) ...
    (comp.infosystems.www.authoring.stylesheets)
  • Re: Compact all the minimized forms into 1 application tag
    ... If I have an application with several forms, you see on the windows ... Now if the bar gets crowded, ... many of them are collapsed in that tag. ... Set the forms ShowInTaskBar property to false... ...
    (microsoft.public.dotnet.languages.vb)
  • Compact all the minimized forms into 1 application tag
    ... If I have an application with several forms, you see on the windows ... Now if the bar gets crowded, windows automatically puts all the ... many of them are collapsed in that tag. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Book/tutorial about SEO
    ... Closing them puts a carriage return which looks funny on the pages ... The web page title bar has a black background. ... tag doesn't have to be closed in HTML but has to in XHTML. ...
    (alt.internet.search-engines)