How to export variable from an JSP 2.0 tag file
From: Treespace (rmacpherson_at_verilet.com)
Date: 02/28/05
- Next message: dar7yl: "Re: Declare question"
- Previous message: SMC: "Re: Homework Help! Urgent!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Next message: dar7yl: "Re: Declare question"
- Previous message: SMC: "Re: Homework Help! Urgent!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|