Thanks to both of you....
I've seen the servlet's code and indeed, Michael,
you're right...
I know deeper the <bean:define> mechanism
now...Thanks!
Cordialement,
----- Original Message -----
Sent: Monday, November 21, 2005 8:07
PM
Subject: Re: <bean:define> and its
behaviour....
Gaet,
This is not a Struts thing, this is a JSP thing.
read <bean:define> documentation [1] and look at the source code
generated by servlet container as James suggested. Documentation states
clearly in the very first sentence that <bean:define> creates "a _new
attribute_ (in the scope specified by the toScope property, if any), and a
corresponding _scripting variable_". Source code, generated by Jasper,
shows that scripting variable is created and initialized with value of JSP
scoped attribute. Then you change the value of scripting variable in
your scriptlet, which is not reflected in any way back in JSP
scoped attribute.
Try to change
<bean:define> tag to <jsp:useBean> to
see a somewhat cleaner code generated by Jasper.
Now the posible
solution: if you change this
<% myVar = "content"; %> to
this <%
pageContext.setAttribute("myVar", "content"); %> you example will work.
The above means to use scoped varable instead of scriptlet variable. Try to
not mix scripting variables with scoped variables. It is easier with JSTL,
which has cleaner syntax and automatically looks up scoped variable in all
scopes. With JSTL the need for scripting variables is greatly
reduced.
[1] http://struts.apache.org/struts-taglib/tagreference-struts-bean.html#bean:define
Michael.
On
11/21/05, James Harig <[EMAIL PROTECTED]>
wrote: > Hi Gaet, > > If you are interested in knowing what
is going on, you can look at the java servlet that is generated from your
.jsp. For Tomcat, the servlets are in the <CATALINA_BASE>/work
directory. > > > -----Original Message----- > From:
Gaet [mailto:[EMAIL PROTECTED] > Sent: Monday, November 21, 2005 12:46
PM > To: Struts Users Mailing List > Subject: Re:
<bean:define> and its behaviour.... > > > Thanks for
reply Michael, > > I mean that it's certainly trivial for
experimented users with struts....not like me :o) > I try to look...but
I can't find the solution....why this variables are
different... > > Cordialement, > > > -----
Original Message ----- > From: Michael <mailto:[EMAIL PROTECTED]>
Jouravlev > To: Struts Users Mailing List <mailto:user@struts.apache.org> >
Sent: Monday, November 21, 2005 5:54 PM > Subject: Re:
<bean:define> and its behaviour.... > > If it is trivial,
why won't you look it up yourself? The key is to > understand that myVar
objects used here > <bean:define id="myVar"
value=""/> > and here > <% myVar =
"content"; %> > are different. > >
Michael. > > On 11/21/05, Gaet < [EMAIL PROTECTED]> wrote: > >
Nobody knows the answer to this trivial question? > > > >
Thanks > > > > > > ----- Original
Message ----- > > From: Gaet > > To:
Mailing List Struts > > Sent: Monday, November 21, 2005
10:08 AM > > Subject: <bean:define> and its
behaviour.... > > > > > > Hi, >
> > > I'm sure this question is easy to answer for
much of yours but I cannot > > figure out the following
behaviour : > > >
>
<bean:define id="myVar" value=""/> >
> <% myVar =
"content"; %> > > >
>
<logic:notEmpty name="myVar"> >
>
<% System.out.println("myVar is NOT EMPTY"); %> >
>
</logic:notEmpty> > > >
>
<logic:empty name="myVar"> >
>
<% System.out.println("myVar is EMPTY"); %> >
>
</logic:empty> > > > > The following
snippet writes "myVar is EMPTY" on standard output, why? >
> What I have to write to have "myVar is NOT EMPTY"? >
> > > Thanks very much for your help > >
--------------------------------------------------------------------- >
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]
|