You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Carsten Ziegeler <cz...@s-und-n.de> on 2004/07/12 08:41:56 UTC

The contract of Request.get() ?

It seems to me that the contract of the get() method on the 
Request object is not defined very well.

The javadoc says:
    /**
     * Returns the value of the named attribute as an <code>Object</code>,
     * or <code>null</code> if no attribute of the given name exists.
     */
So, from this I would conclude that it's the same as getAttribute(name),
so it's superfluous.
In fact, the CLI Request object does implement it in this way.

But :) the http request implementation, does the following:

    if (req instanceof MultipartHttpServletRequest) {
        return ((MultipartHttpServletRequest) req).get(name);
    } else {
        // This is a shortened version of the exact code:
        return req.getParameterValues(name);
    }

So, this implementation is not about attributes at all! Looking through
our code, it seems get() is used whenever it comes to handle an uploaded
file.

I think we should correct the javadocs and the implementation
for the CLI.

WDYT?

Carsten 

Carsten Ziegeler 
Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.net/weblogs/rael/


Re: The contract of Request.get() ?

Posted by Sylvain Wallez <sy...@apache.org>.
Carsten Ziegeler wrote:

>It seems to me that the contract of the get() method on the 
>Request object is not defined very well.
>  
>

To say the least ;-)

>The javadoc says:
>    /**
>     * Returns the value of the named attribute as an <code>Object</code>,
>     * or <code>null</code> if no attribute of the given name exists.
>     */
>So, from this I would conclude that it's the same as getAttribute(name),
>so it's superfluous.
>In fact, the CLI Request object does implement it in this way.
>
>But :) the http request implementation, does the following:
>
>    if (req instanceof MultipartHttpServletRequest) {
>        return ((MultipartHttpServletRequest) req).get(name);
>    } else {
>        // This is a shortened version of the exact code:
>        return req.getParameterValues(name);
>    }
>
>So, this implementation is not about attributes at all! Looking through
>our code, it seems get() is used whenever it comes to handle an uploaded
>file.
>  
>

We can consider that the contract of get() is to return request 
*parameters* (and not attributes) in an object form when special 
processing has been made on these parameters. And the only parameters 
that currently have a special processing are file uploads.

>I think we should correct the javadocs and the implementation for the CLI.
>  
>

+1. As uploads have no meaning for CLI, this should be same as 
request.getParameter()

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }