We exist to serve.  :-)

R

----- Original Message ----- 
From: "otisg" <[EMAIL PROTECTED]>
To: "Hans Bergsten" <[EMAIL PROTECTED]>
Sent: Tuesday, December 09, 2003 11:45 AM
Subject: Re: Re: c:forEach, c:import and variable scope?


> Wow, thanks for quick replies (problem not 100% solved, but all
> replies helped!)
> Comment below.
> 
> ---- On Tue, 09 Dec 2003, Hans Bergsten
> ([EMAIL PROTECTED]) wrote:
> 
> > Karr, David wrote:
> > > I can't see how that could work.  The "c:import" operation
> is processing
> > > that URL in an external context.  You'd probably have to
> use
> > > "jsp:include" for that sort of thing.
> > 
> > Actually, the problem is that <c:forEach> exposes the current
> element
> > through a _page_ scope variable named by the "var" attribute,
> and an
> > included page (whether by <c:import> or <jsp:include>) doesn't
> see
> > page scope variables.
> 
> Right, that is why I tried using c:set with session="request",
> exactly as you wrote below.  That didn't work with c:import.
> 
> I did try <%@ include file="some/page.jsp" %> and that worked. 
> I would still prefer a more JSTL-ish way.
> 
> > You can "promote" the variable to request scope, which is seen
> by the
> > included page:
> > 
> >    [c:forEach var="foo" items="${bars}"]
> >      [c:set var="foo" scope="request" value="${foo}"/]
> >      [c:import url="some/page.jsp"/]
> >     [/c:forEach]
> 
> This didn't work for me with JBoss/Jetty (not the latest and
> greatest).
> 
> I am trying the suggestion with c:param enclosed in c:import
> now...
> 
> Otis
> 
> 
> > or, if you use JSP 2.0, use a "tag file" custom action instead
> of
> > including a different JSP page. See the sample chapter from
> the 3rd
> > edition of my JSP book (should be in the stores any day now)
> for more
> > about tag files:
> > 
> >   
> <http://www.oreilly.com/catalog/jserverpages3/chapter/index.html>
> > 
> > Hans
> > 
> > >>-----Original Message-----
> > >>From: otisg [mailto:[EMAIL PROTECTED] 
> > >>
> > >>Here is the problem (using [] to avoid problems with email
> > >>clients not handling HTML well).
> > >>
> > >>Summary:
> > >>c:forEach loop, inside it c:import, but the c:import-ed JSP
> does
> > >>not see the var from the c:forEach loop.
> > >>
> > >>[c:forEach var="foo" items="${bars}"]
> > >>  [c:import url="some/page.jsp"/]
> > >>[/c:forEach]
> > >>
> > >>In this page.jsp I try to access ${foo}, like so:
> > >>[c:out value="${foo}"/]
> > >>
> > >>No go.  ${foo} seems undefined there :(  page.jsp does not
> see
> > >>it.  Scope issue?
> > >>
> > >>I then tried adding the following inside that c:forEach:
> > >>[c:set var="newFoo" value="${foo}" scope="request"/]
> > >>
> > >>However, that c:import-ed page.jsp does not see ${newFoo}
> > >>either. :(
> > >>
> > >>I am using jakarta-taglibs 1.0.3 with JBoss/Jetty.
> > >>
> > >>Is the above supposed to work?
> > >>How do I get the import-ed page.jsp to see a variable
> defined in
> > >>the page that imported it?
> > >>
> > >>Thanks,
> > >>Otis
> > 
> > 
> > -- 
> > Hans Bergsten                               
> <[EMAIL PROTECTED]>
> > Gefion Software                      
> <http://www.gefionsoftware.com/>
> > Author of O'Reilly's "JavaServer Pages", covering JSP 2.0 and
> JSTL 1.1
> > Details at                                   
> <http://TheJSPBook.com/>
> > 
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> > For additional commands, e-mail:
> [EMAIL PROTECTED]
> > 
> > 
> > 
> 
> 
> ________________________________________________
> Get your own "800" number
> Voicemail, fax, email, and a lot more
> http://www.ureach.com/reg/tag
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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

Reply via email to