You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by Christopher Lenz <cm...@gmx.de> on 2002/01/18 18:23:40 UTC

[standard] auto-add request parameters as attributes ?

Hi jstl-developers,

While playing with JSTL EA3, I've encountered some problems:

- It would be nice if there was a way to directly use request-parameters in 
evaluated expressions. The only way I've found to access parameters is to 
explicitly add them to the page attributes (using a scriptlet or another 
taglib). How about either:
  (a) automatically adding the parameter to the page attributes or
  (b) adding an associative container ('params' or sth) to the page 
      attributes, that contains all the parameters
  (I'm not sure how the expression evaluation support is designed, but when I 
  say 'added to the attributes' I actually mean 'included in the evaluation'.)

- Having some implicit objects usable in expressions would be nice, similar to 
  the implicit scripting variables request, response, etc.

- I think there's a bug in org.apache.taglibs.standard.tag.el.core.ExprTag, 
  in the method doEndTag(): 

    // verify and print out the body
    String bcs = getBodyContent().getString();
    if (bcs == null || bcs.trim().equals(""))
        throw new JspTagException(
             Resources.getMessage("EXPR_BAD_VALUE", value));
    getBodyContent().writeOut(pageContext.getOut());

  Here (bcs == null) is checked after the getString() has been called on the 
  object, which makes the check kind of useless, because there'll be a
  NPE thrown.

Other than that I think JSTL is looking pretty cool, especially with the ECMA-
Script support.

-chris
_______________________________________________
 /=/ cmlenz at gmx.de




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [standard] auto-add request parameters as attributes ?

Posted by Christopher Lenz <cm...@gmx.de>.
Hey Shawn-
thanks for the response...

18.01.2002 18:27:36, Shawn Bayern <ba...@essentially.net> wrote:
[...]
>> - I think there's a bug in 
org.apache.taglibs.standard.tag.el.core.ExprTag, 
>>   in the method doEndTag(): 
>> 
>>     // verify and print out the body
>>     String bcs = getBodyContent().getString();
>>     if (bcs == null || bcs.trim().equals(""))
>>         throw new JspTagException(
>>              Resources.getMessage("EXPR_BAD_VALUE", value));
>>     getBodyContent().writeOut(pageContext.getOut());
>> 
>>   Here (bcs == null) is checked after the getString() has been 
called on the 
>>   object, which makes the check kind of useless, because there'll 
be a
>>   NPE thrown.
>
>No, the check is as intended.  BodyContent cannot be null because, 
>just before the code you show, we check to make sure a body is 
>necessary before running this code.  (A body is only necessary if the 
>'value' attribute isn't present.)  If value isn't present and this 
>code thus gets executed at runtime, we can be sure at runtime that 
>there's an actual BodyContent; if there weren't, the case would be 
>caught by translation-time validation.

Okay, then in my case the validator didn't seem to catch it, but I 
can't check right now 'cause I'm not close to the machine where I was 
testing.

[...]

-chris
________________________________________________________________
cmlenz at gmx.de




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [standard] auto-add request parameters as attributes ?

Posted by Shawn Bayern <ba...@essentially.net>.
Hi Christopher.  Thanks for for your comments.  I've intermixed comments
below --

On Fri, 18 Jan 2002, Christopher Lenz wrote:

> - It would be nice if there was a way to directly use request-parameters in 
> evaluated expressions. The only way I've found to access parameters is to 
> explicitly add them to the page attributes (using a scriptlet or another 
> taglib). How about either:
>   (a) automatically adding the parameter to the page attributes or
>   (b) adding an associative container ('params' or sth) to the page 
>       attributes, that contains all the parameters
>   (I'm not sure how the expression evaluation support is designed, but when I 
>   say 'added to the attributes' I actually mean 'included in the evaluation'.)

This is a function of the expression language, which is currently being
debated in the appropriate expert group.  We fully expect that the final
expression language will support direct retrieval of request parameters as
Strings.  Currently, the "SPEL" expression language (included with the
early-access RI) does allow direct retrieval.

> - I think there's a bug in org.apache.taglibs.standard.tag.el.core.ExprTag, 
>   in the method doEndTag(): 
> 
>     // verify and print out the body
>     String bcs = getBodyContent().getString();
>     if (bcs == null || bcs.trim().equals(""))
>         throw new JspTagException(
>              Resources.getMessage("EXPR_BAD_VALUE", value));
>     getBodyContent().writeOut(pageContext.getOut());
> 
>   Here (bcs == null) is checked after the getString() has been called on the 
>   object, which makes the check kind of useless, because there'll be a
>   NPE thrown.

No, the check is as intended.  BodyContent cannot be null because, just
before the code you show, we check to make sure a body is necessary before
running this code.  (A body is only necessary if the 'value' attribute
isn't present.)  If value isn't present and this code thus gets executed
at runtime, we can be sure at runtime that there's an actual BodyContent;
if there weren't, the case would be caught by translation-time validation.

The check against null is to ensure that the *String* returned from
BodyContent isn't null before trimming it; this is just a defensive check.

Thanks for the comments,

Shawn Bayern
JSTL reference-implementation lead


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>