RE: JSTL Bug - requestScope[var] not working

2002-11-21 Thread Shawn Bayern
On Thu, 21 Nov 2002, Scott Goldstein wrote:

> I'm not sure that I follow.  How about these two snippets:
> 
> <%
>  String value = "foo";
> %>
> 
> 
> 
> and
> 
> 
> 
> The second one works, while the first doesn't.

Yes.  Again, this is correct.  In fact, the problem is the same:  in the
first example (which is the same as what you showed before), 'value' is
simply a scripting variable.  It is not automatically visible to the EL;
the EL has no way to read scripting variables.  Instead, it must be made a
scoped variable explicitly, as by pageContext.setAttribute().

> The only difference is that the second is using a string literal for
> the index and the first is using a scripting variable.  Are you saying
> that scripting variables cannot be used as indexes?

I'm saying that scripting variables cannot be accessed at all by the EL.
Any EL-accessible values can be used as indices.

Shawn


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: JSTL Bug - requestScope[var] not working

2002-11-21 Thread Karr, David
If Shawn's response wasn't clear, I'm not sure what else we can say.  The EL parser 
doesn't read scripting variables.  It doesn't know anything about them.  It can't use 
them.  Your first example doesn't work because it's trying to reference a scripting 
variable.  From the EL's point of view, there is no "value" scoped attribute, so the 
result is null.

You should read the specification, if you haven't yet.

> -Original Message-
> From: Scott Goldstein [mailto:[EMAIL PROTECTED]]
> 
> I'm not sure that I follow.  How about these two snippets:
> 
> <%
>  String value = "foo";
> %>
> 
> 
> 
> and
> 
> 
> 
> The second one works, while the first doesn't.  The only 
> difference is that 
> the second is using a string literal for the index and the 
> first is using a 
> scripting variable.  Are you saying that scripting variables 
> cannot be used as 
> indexes?
> 
> Basically, prior to this jsp being executed, I've done the following:
> 
> request.setAttribute("foo", "SomeTextToRetrieve");
> 
> So, what I think should happen in the first snippet, is that 
> the variable, 
> value, is resolved to it's String literal, "foo" and then the 
> expression is 
> evaluated just like the second snippet.  This does not appear 
> to be happening.
> 
> Scott
> 
> >= Original Message From Shawn Bayern 
> <[EMAIL PROTECTED]> =
> >On Thu, 21 Nov 2002, Scott Goldstein wrote:
> >
> >> I think this may have already been posted, but I don't recall the
> >> answer.
> >>
> >> Aren't the following two snippets identical?
> >>
> >> <%
> >> String value = "foo";
> >> %>
> >>
> >> 
> >>
> >> and
> >>
> >> <%= request.getAttribute(value) %>
> >
> >Nope.  Scripting variables are not automatically made into scoped
> >attributes, and the EL can only refer to scoped attributes.  
> If you added
> >
> >  pageContext.setAttribute("foo", foo);
> >
> >to the upper scriptlet, then the code would be identical.
> >
> >> The first is returning null and the second is returning the
> >> appropriate attribute value.  I looked in the JSTL spec 
> and it looks
> >> like the first should work.
> >>
> >> Is this a bug?
> >
> >No, the behavior is as expected.

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: JSTL Bug - requestScope[var] not working

2002-11-21 Thread Henri Yandell

I seem to have a wonderful ability to not see Shawn's replies. Sorry
Shawn.

On Thu, 21 Nov 2002, Henri Yandell wrote:

>
> I get pretty stupid with JSTL sometimes, but aren't you trying to treat
> requestScope as a map?
>
> ie) it should be requestScope.var?
>
> Other useful things that took me a while to get:
>
> request.getParameter("Xxx") is available as:
>
> param.Xxx
>
> and the request itself can be got to via:
>
> pageContext.request.remoteUser
>
>
> [jsut trying to help until one of the real JSTL guys shows up :) ]
>
> Hen
>
> On Thu, 21 Nov 2002, Scott Goldstein wrote:
>
> > I think this may have already been posted, but I don't recall the
> > answer.
> >
> > Aren't the following two snippets identical?
> >
> > <%
> > String value = "foo";
> > %>
> >
> > 
> >
> > and
> >
> > <%= request.getAttribute(value) %>
> >
> > The first is returning null and the second is returning the appropriate
> > attribute value.  I looked in the JSTL spec and it looks like the first
> > should work.
> >
> > Is this a bug?
> >
> > Thanks.
> >
> > Scott
> >
> >
> > --
> > To unsubscribe, e-mail:   
> > For additional commands, e-mail: 
> >
> >
>
>
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
>
>


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: JSTL Bug - requestScope[var] not working

2002-11-21 Thread Henri Yandell

I get pretty stupid with JSTL sometimes, but aren't you trying to treat
requestScope as a map?

ie) it should be requestScope.var?

Other useful things that took me a while to get:

request.getParameter("Xxx") is available as:

param.Xxx

and the request itself can be got to via:

pageContext.request.remoteUser


[jsut trying to help until one of the real JSTL guys shows up :) ]

Hen

On Thu, 21 Nov 2002, Scott Goldstein wrote:

> I think this may have already been posted, but I don't recall the
> answer.
>
> Aren't the following two snippets identical?
>
> <%
> String value = "foo";
> %>
>
> 
>
> and
>
> <%= request.getAttribute(value) %>
>
> The first is returning null and the second is returning the appropriate
> attribute value.  I looked in the JSTL spec and it looks like the first
> should work.
>
> Is this a bug?
>
> Thanks.
>
> Scott
>
>
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
>
>


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: JSTL Bug - requestScope[var] not working

2002-11-21 Thread Shawn Bayern
On Thu, 21 Nov 2002, Scott Goldstein wrote:

> I think this may have already been posted, but I don't recall the
> answer.
> 
> Aren't the following two snippets identical?
> 
> <%
> String value = "foo";
> %>
> 
> 
> 
> and
> 
> <%= request.getAttribute(value) %>

Nope.  Scripting variables are not automatically made into scoped
attributes, and the EL can only refer to scoped attributes.  If you added

  pageContext.setAttribute("foo", foo);

to the upper scriptlet, then the code would be identical.

> The first is returning null and the second is returning the
> appropriate attribute value.  I looked in the JSTL spec and it looks
> like the first should work.
> 
> Is this a bug?

No, the behavior is as expected.

-- 
Shawn Bayern
"JSTL in Action"   http://www.manning.com/bayern


--
To unsubscribe, e-mail:   
For additional commands, e-mail: