sling-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Edelson <jus...@justinedelson.com>
Subject Re: SlingServlets - Query Params making listener break
Date Fri, 10 Jun 2011 02:14:25 GMT
I'd suggest using the recent requests web console plugin to see how the request is getting
decomposed.

Justin

On Jun 9, 2011, at 7:30 PM, "David G." <davidjgonzalez@gmail.com> wrote:

> I have a Sling Servlet that Im creating .. It seems to be working just
> fine until i pass a query parameter to it.
> 
> Ex.
> 
> http://example.com/libs/logout.html > logs the user out
> 
> http://example.com/libs/logout.html?resource=/bar/foo.html > does not
> even call the servlet
> 
> 
> 
> It appears the Sling Servlet is ignoring any requests to its base path
> if there are query params involved. Any ideas how to get around this?
> Is this expected behavior?
> 
> Thanks
> 
> -------------------------
> Pretty Pastie of code snippet: http://www.pastie.org/2045227
> 
> 
> --------------------------------
> Ugly email snippet:
> 
> 
> /**
> *
> * @scr.component immediate="true" description="Logout Servlet"
> * @scr.service interface="javax.servlet.Servlet"
> * @scr.property name="sling.servlet.extensions" values.0 = "html"
> * @scr.property name="sling.servlet.methods" values.0 = "GET"
> * @scr.property name="sling.servlet.paths" value="/libs/logout"
> */
> @SuppressWarnings("serial")
> public class LogoutSlingServlet extends SlingAllMethodsServlet {
> 
>    /**
>     * @scr.reference
>     */
>    Authenticator auth;
> 
>    @Override
>    protected void doGet(SlingHttpServletRequest request,
>            SlingHttpServletResponse response) throws ServletException,
>            IOException {
> 
>        String redirectUri = request.getParameter("resource");
> 
>        if(redirectUri == null) {
>            redirectUri = "/foo.html";
>        }
> 
>        System.out.println(redirectUri);
> 
>        if (auth != null) {
>            try {
>                auth.logout(request, response);
>            } catch (Exception ex) {
>                response.sendError("Could not log user out");
>            }
>        }
> 
>        response.sendRedirect(redirectUri);
>        return;
> 
>    }

Mime
View raw message