You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by "David G." <da...@gmail.com> on 2012/12/13 23:48:01 UTC

[Bug?] Sling.forward() breaking on Query Params

Hey all,

Should this be considered a bug? It seems like sling.forward() or even explicitly using RequestDispather.forward() throws a resource not found exception if the path has Query params.  Same for include(..).

In my case the path points to a functioning servlet.

The Java Servlet Spec seems to think it should work. Am I missing something -- I tend to give you guys the benefit of the doubt that the error is on my end ;)

Thanks!

-------

String  test1 = "/bin/myservlet.json";
String  test2 = "/bin/myservlet.json?foo=bar";


sling.forward(test1);
slingRequest.getRequestDispatcher(test1).forward(request, response);
// Works

sling.forward(test2);
slingRequest.getRequestDispatcher(test2).forward(request, response);

// Resource Not Found exception

-------
SRV.8.1.1 Query Strings in Request Dispatcher Paths The ServletContext and ServletRequest methods that create RequestDispatcher objects using path information allow the optional attachment of query string information to the path. For example, a Developer may obtain a RequestDispatcher by using the following code: String path = “/raisins.jsp?orderno=5”; RequestDispatcher rd = context.getRequestDispatcher(path); rd.include(request, response); Parameters specified in the query string used to create the RequestDispatcher take precedence over other parameters of the same name passed to the included servlet. The parameters associated with a RequestDispatcher are scoped to apply only for the duration of the include or forward call.





--  
David Gonzalez
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


Re: [Bug?] Sling.forward() breaking on Query Params

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Fri, Dec 14, 2012 at 12:17 PM, Felix Meschberger <fm...@adobe.com> wrote:
> ...let me repeat the OpenSource mantra: Patches welcome ;-)...

In this case I'd say "with automated tests"...this is a core component
that shouldn't be modified without good before/after test coverage
IMO.

-Bertrand

Re: [Bug?] Sling.forward() breaking on Query Params

Posted by David Gonzalez <da...@gmail.com>.
Felix - thanks for the feedback. So feature request not bug. Thanks
for confirming/correcting.

And read you loud and clear wrt to the patches. :)

Sent from my iPhone

On Dec 14, 2012, at 3:17 AM, Felix Meschberger <fm...@adobe.com> wrote:

> Hi,
>
> Sling's request dispatcher implementation does not support request parameters. We never needed it and thus never implemented it.
>
> Yes, this is kind of a violation and having support for request parameters would be great, probably.
>
> Along these lines, let me repeat the OpenSource mantra: Patches welcome ;-)
>
> Thanks and Regards
> Felix
>
> Am 13.12.2012 um 23:48 schrieb David G.:
>
>> Hey all,
>>
>> Should this be considered a bug? It seems like sling.forward() or even explicitly using RequestDispather.forward() throws a resource not found exception if the path has Query params.  Same for include(..).
>>
>> In my case the path points to a functioning servlet.
>>
>> The Java Servlet Spec seems to think it should work. Am I missing something -- I tend to give you guys the benefit of the doubt that the error is on my end ;)
>>
>> Thanks!
>>
>> -------
>>
>> String  test1 = "/bin/myservlet.json";
>> String  test2 = "/bin/myservlet.json?foo=bar";
>>
>>
>> sling.forward(test1);
>> slingRequest.getRequestDispatcher(test1).forward(request, response);
>> // Works
>>
>> sling.forward(test2);
>> slingRequest.getRequestDispatcher(test2).forward(request, response);
>>
>> // Resource Not Found exception
>>
>> -------
>> SRV.8.1.1 Query Strings in Request Dispatcher Paths The ServletContext and ServletRequest methods that create RequestDispatcher objects using path information allow the optional attachment of query string information to the path. For example, a Developer may obtain a RequestDispatcher by using the following code: String path = “/raisins.jsp?orderno=5”; RequestDispatcher rd = context.getRequestDispatcher(path); rd.include(request, response); Parameters specified in the query string used to create the RequestDispatcher take precedence over other parameters of the same name passed to the included servlet. The parameters associated with a RequestDispatcher are scoped to apply only for the duration of the include or forward call.
>>
>>
>>
>>
>>
>> --
>> David Gonzalez
>> Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
>

Re: [Bug?] Sling.forward() breaking on Query Params

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

Sling's request dispatcher implementation does not support request parameters. We never needed it and thus never implemented it.

Yes, this is kind of a violation and having support for request parameters would be great, probably.

Along these lines, let me repeat the OpenSource mantra: Patches welcome ;-)

Thanks and Regards
Felix

Am 13.12.2012 um 23:48 schrieb David G.:

> Hey all,
> 
> Should this be considered a bug? It seems like sling.forward() or even explicitly using RequestDispather.forward() throws a resource not found exception if the path has Query params.  Same for include(..).
> 
> In my case the path points to a functioning servlet.
> 
> The Java Servlet Spec seems to think it should work. Am I missing something -- I tend to give you guys the benefit of the doubt that the error is on my end ;)
> 
> Thanks!
> 
> -------
> 
> String  test1 = "/bin/myservlet.json";
> String  test2 = "/bin/myservlet.json?foo=bar";
> 
> 
> sling.forward(test1);
> slingRequest.getRequestDispatcher(test1).forward(request, response);
> // Works
> 
> sling.forward(test2);
> slingRequest.getRequestDispatcher(test2).forward(request, response);
> 
> // Resource Not Found exception
> 
> -------
> SRV.8.1.1 Query Strings in Request Dispatcher Paths The ServletContext and ServletRequest methods that create RequestDispatcher objects using path information allow the optional attachment of query string information to the path. For example, a Developer may obtain a RequestDispatcher by using the following code: String path = “/raisins.jsp?orderno=5”; RequestDispatcher rd = context.getRequestDispatcher(path); rd.include(request, response); Parameters specified in the query string used to create the RequestDispatcher take precedence over other parameters of the same name passed to the included servlet. The parameters associated with a RequestDispatcher are scoped to apply only for the duration of the include or forward call.
> 
> 
> 
> 
> 
> --  
> David Gonzalez
> Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
>