Thanks Cedric for your help.
Does template:put can actually put an object other than String?
That is:
<% AClass aObject = new AClass(); %>
...
<template:put name="myObject" content='<%=aObject%>' >
...
And, then, how are we going to get the boject back?
I guess that's where your proposal to extend the template tag comes in.
In any rate, I have a work around for now, which is to use the
request.setAttribute(...) and request.getAttribute(...)
to pass and retrieve objects between those files involved in the template.
It is not convenient, but, I guess that's what I have to do at the moment.
Again, many thanks for your help.
-Hay
----- Original Message -----
From: "Cedric Dumoulin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 21, 2000 6:13 AM
Subject: Re: How can I use a java variable that was defined in the enclosing
template tag?
>
> I have misspell the Components Proposal URL !
> try : http://gauss.ficsgrp.com/cdm/
>
> Cedric
>
> Cedric Dumoulin wrote:
>
> > Hay,
> >
> > You can't use a java variable defined in a page inside included page.
> > You need to define your variable in a scope (here request, but can
> > also be session or application).
> > An alternative to your problem could also be :
> > <% String strToBeUsedByPageA = "Hello";%> <template:insert
> > template='aTemplate.jsp'> <template:put name=''myString"
> > value='<%=strToBeUsedByPageA%>' direct="true" ></template:insert>
> >
> > and use <template:get name="myString" />
> >
> > You can also have a look to my "extended template proposal" at
> > http=//gauss.ficsgrp.com/cdm. You will find more solutions to pass
> > values to
> > an included template.
> >
> > Cedric
> >
> > As an example, another solution to your problem is (with extended
> > templates) :
> > <% String strToBeUsedByPageA = "Hello";%> <template:insert
> > template='aTemplate.jsp'> <template:put name=''myString"
> > value='<%=strToBeUsedByPageA%>' ></template:insert>
> >
> > and use
> > <template:useAttribute id="strToBeUsedByPageA" name="myString" />
> >
> > value = <%="strToBeUsedByPageA" />
> >
> > Hay Tran wrote:
> >
> > > Here is an example:// Here is the code segment for the enclosing tag,
> > > the template:insert ........<% String strToBeUsedByPageA =
> > > "Hello";%> <template:insert template='aTemplate.jsp'> <template:put
> > > name='PageA.jsp'></template:insert> // Here is the code segment for
> > > the enclosed file, PageA....The enclosing tag defined the
> > > strToBeUsedByPageA variable that is being displayed
> > > here:<%=strToBeUsedByPageA %>... // I get the error msg saying
> > > strToBeUsedByPageA is not define. Thanks for any help I can
> > > get. -Hay
>
>