You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Felix Meschberger <fm...@gmail.com> on 2008/10/13 13:26:53 UTC

Request Attributes on RequestDispatcher.include

Hi all,

The SlingRequestDispatcher implements the Servlet API RequestDispatcher
interface and is created upon any client calling any of the
SlingHttpServletRequest.getRequestDispatcher methods. The
SlingRequestDispatcher is also the base for the <sling:include> JSP tag
and the SlingScriptHelper.include implementation.

The ServletAPI defines the following request attributes to be set
whenever a resource/servlet is included by RequestDispatcher.include():

    javax.servlet.include.request_uri
    javax.servlet.include.context_path
    javax.servlet.include.servlet_path
    javax.servlet.include.path_info
    javax.servlet.include.query_string

These request attributes are not currently set by the
SlingRequestDispatcher implementation.

On the other hand, we set the following request attributes when
including resources:

    org.apache.sling.api.include.servlet
    org.apache.sling.api.include.resource

Now I wonder, whether we should:

  (1) set the javax.servlet.include.* attributes upon include ?
      --> Probably yes for standards compliance

  (2) define a new property
         org.apache.sling.api.include.path_info
      taking the SLingHttpServletRequest.getRequestPathInfo()

WDYT ?

BTW, in contrast to the javax.servlet.include.* request attributes which
are only set up calling the RequestDispatcher.include method, the
org.apache.sling.api.include.* request attributes are set when calling
the RequestDispatcher.include and RequestDispatcher.forward method.


Regards
Felix

Re: Request Attributes on RequestDispatcher.include

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Mon, Oct 13, 2008 at 1:26 PM, Felix Meschberger <fm...@gmail.com> wrote:

> ...I wonder, whether we should:
>
>  (1) set the javax.servlet.include.* attributes upon include ?
>      --> Probably yes for standards compliance

+1

>  (2) define a new property
>         org.apache.sling.api.include.path_info
>      taking the SLingHttpServletRequest.getRequestPathInfo()...

Like Alex, I'm +1 assuming there's a use for this.

Using this requires the Sling API classes (as the value is a
RequestPathInfo object), so we might as well require that people cast
the Request object to SlingHttpServletRequest.

-Bertrand

Re: Request Attributes on RequestDispatcher.include

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Alexander Klimetschek schrieb:
> On Mon, Oct 13, 2008 at 1:26 PM, Felix Meschberger <fm...@gmail.com> wrote:
>>  (1) set the javax.servlet.include.* attributes upon include ?
>>      --> Probably yes for standards compliance
> 
> +1 if this helps to use more non-Sling servlets inside Sling without
> modification
> 
>>  (2) define a new property
>>         org.apache.sling.api.include.path_info
>>      taking the SLingHttpServletRequest.getRequestPathInfo()
> 
> Generally I would say yes, since request attributes with a unique name
> shouldn't have a disadvantage, so just add them. On the other hand it
> is hard to image someone using the attribute, because if a servlet is
> sling-aware, it would rather cast to SlingHttpServletRequest to get
> this information, or can the property be used in more situations than
> the SlingHSR object?

Just to clarify, this is the RequestPathInfo of the including script, it
is not the current one, which may well be different. In addition, this
attribute is of course only set on included servlets/scripts.


Regards
Felix

Re: Request Attributes on RequestDispatcher.include

Posted by Alexander Klimetschek <ak...@day.com>.
On Mon, Oct 13, 2008 at 1:26 PM, Felix Meschberger <fm...@gmail.com> wrote:
>  (1) set the javax.servlet.include.* attributes upon include ?
>      --> Probably yes for standards compliance

+1 if this helps to use more non-Sling servlets inside Sling without
modification

>  (2) define a new property
>         org.apache.sling.api.include.path_info
>      taking the SLingHttpServletRequest.getRequestPathInfo()

Generally I would say yes, since request attributes with a unique name
shouldn't have a disadvantage, so just add them. On the other hand it
is hard to image someone using the attribute, because if a servlet is
sling-aware, it would rather cast to SlingHttpServletRequest to get
this information, or can the property be used in more situations than
the SlingHSR object?

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com