Let's be explicit, here.  A scripting variable is a variable that actually
gets declared in the JSP page implementation class, as a local variable
within the main processing method of that class.  It is *not* the same thing
as a page scoped attribute.

Scriptlets rely on the former and require that custom tags wishing to expose
such implement the usually optional TagExtraInfo class.  JSTL and Struts
rely on the later and tend to be, IMHO, cleaner and more flexible.  To make
a Struts or JSTL scoped variable available to a scriptlet, you *must*
declare a variable so that it will end up being declared as a local variable
in the underlying parsed class and somehow retrieve it from the appropriate
scope and assign it to the declared variable or it will *not* be available
to a runtime expression.

For the record, I agree that scriptlets are nasty and it would be better if
in this case you used an EL capable tag instead of <jsp:include>, like
<c:import>, however I was assuming the original poster only had the
<jsp:include> tag available.

Thomas Gideon
Sr. Software Developer
B2eMarkets

301.230.2236  Tel.
301.230.2248  Fax.
[EMAIL PROTECTED]
www.B2eMarkets.com



> -----Original Message-----
> From: Eddie Bush [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 17, 2002 5:52 PM
> To: Struts Users Mailing List
> Subject: Re: newbie include question
> 
> 
> Or you could use <bean:define> or <jsp:useBean> ... OR you 
> could use <c:set>
> 
> There are a myriad of ways to introduce scripting variables without 
> introducing scriplets into your code-base.
> 
> Gideon, Thomas wrote:
> 
> >>-----Original Message-----
> >>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> >>
> >>I think you could use the syntax:
> >>
> >><jsp:include page="/page.jsp" flush="true"> 
> >>    <jsp:param name="yourVariable" value="<%=variable%>"/>
> >></jsp:include>
> >>
> >
> >This will work if variable is a *scripting* variable 
> already.  If it is a
> >form bean, then you may have to add a scriptlet, first, like:
> >
> ><%
> >Object variable = pageContext.findAttribute("variable");
> >%>
> >
> >otherwise your runtime expression may cause a JSP compilation error
> >complaining about an undefined symbol, variable.
> >
> >Thomas Gideon
> >Sr. Software Developer
> >B2eMarkets
> >
> >301.230.2236  Tel.
> >301.230.2248  Fax.
> >[EMAIL PROTECTED]
> >www.B2eMarkets.com
> >
> 
> -- 
> Eddie Bush
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to