sling-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Gonzalez <davidjgonza...@gmail.com>
Subject Re: SlingServlets - Query Params making listener break
Date Fri, 10 Jun 2011 03:18:03 GMT
Justin,

Thanks .. it turns out that the issue was the query parameter was named "resource" which appears
to be a reserved parameter name in Sling. Changing it to "redirect" allows me to hook into
my custom servlet.

I am running into a strange issue now that my Servlet will only be executed if the 
* @scr.property name="sling.servlet.paths" has a value that being with "/libs" or "/apps"


If i put it to anything else, it the request initially is mapped to my custom servlet but
then gets hijacked by the DefaultGetServlet. IN the recent requests Web Console i can see
that Sling is able to resolve to my SimpleSlingServlet, however the DefaultGetServlet ends
up being executed. Any thoughts on why this is for anything not under /libs or /apps?


---------
Pretty Pastie of recently requested: 
http://pastie.org/2045907



-----------
Ugly Text Dump

0 (2011-06-09 23:14:41) TIMER_START{Request Processing}
 0 (2011-06-09 23:14:41) COMMENT timer_end format is {<elapsed msec>,<timer name>}
<optional message>
 0 (2011-06-09 23:14:41) LOG Method=GET, PathInfo=/accounts/logout.html
 0 (2011-06-09 23:14:41) TIMER_START{ResourceResolution}
 0 (2011-06-09 23:14:41) TIMER_END{0,ResourceResolution} URI=/accounts/logout.html resolves
to Resource=ServletResource, servlet=com.test.dm.svc.SimpleSlingServlet, path=/accounts/logout
 0 (2011-06-09 23:14:41) LOG Resource Path Info: SlingRequestPathInfo: path='/accounts/logout',
selectorString='null', extension='html', suffix='null'
 0 (2011-06-09 23:14:41) TIMER_START{ServletResolution}
 0 (2011-06-09 23:14:41) TIMER_START{resolveServlet(ServletResource, servlet=com.test.dm.svc.SimpleSlingServlet,
path=/accounts/logout)}
 1 (2011-06-09 23:14:41) TIMER_END{1,resolveServlet(ServletResource, servlet=com.test.dm.svc.SimpleSlingServlet,
path=/accounts/logout)} Using servlet org.apache.sling.servlets.get.DefaultGetServlet
 1 (2011-06-09 23:14:41) TIMER_END{1,ServletResolution} URI=/accounts/logout.html handled
by Servlet=org.apache.sling.servlets.get.DefaultGetServlet
 1 (2011-06-09 23:14:41) LOG Applying Requestfilters
 1 (2011-06-09 23:14:41) LOG Calling filter: org.apache.sling.bgservlets.impl.BackgroundServletStarterFilter
 1 (2011-06-09 23:14:41) LOG Calling filter: org.apache.sling.portal.container.internal.request.PortalFilter
 1 (2011-06-09 23:14:41) LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter
 1 (2011-06-09 23:14:41) LOG Calling filter: com.day.cq.wcm.core.impl.WCMRequestFilter
 1 (2011-06-09 23:14:41) LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter
 1 (2011-06-09 23:14:41) LOG Calling filter: com.day.cq.theme.impl.ThemeResolverFilter
 2 (2011-06-09 23:14:41) LOG Calling filter: com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet
 2 (2011-06-09 23:14:41) LOG Calling filter: org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter
 2 (2011-06-09 23:14:41) LOG Calling filter: com.day.cq.wcm.mobile.core.impl.redirect.RedirectFilter
 3 (2011-06-09 23:14:41) LOG RedirectFilter did not redirect (MobileUtil.isMobileResource()
returns false)
 3 (2011-06-09 23:14:41) LOG Applying Componentfilters
 3 (2011-06-09 23:14:41) LOG Calling filter: com.day.cq.wcm.core.impl.WCMComponentFilter
28 (2011-06-09 23:14:41) LOG Calling filter: com.day.cq.wcm.core.impl.WCMDebugFilter
29 (2011-06-09 23:14:41) TIMER_START{org.apache.sling.servlets.get.DefaultGetServlet#0}
29 (2011-06-09 23:14:41) LOG No renderer for extension html
29 (2011-06-09 23:14:41) TIMER_START{handleError:status=404}
31 (2011-06-09 23:14:41) TIMER_END{2,handleError:status=404} Using handler /libs/sling/servlet/errorhandler/404.jsp
35 (2011-06-09 23:14:41) TIMER_END{6,handleError:status=404} Error handler finished
35 (2011-06-09 23:14:41) TIMER_END{6,org.apache.sling.servlets.get.DefaultGetServlet#0}
35 (2011-06-09 23:14:41) TIMER_END{35,Request Processing} Request Processing




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

On Thursday, June 9, 2011 at 10:28 PM, David Gonzalez wrote:

> Justin,
> 
> 
> 
> 
> -- 
> David Gonzalez
> Sent with Sparrow (http://www.sparrowmailapp.com)
> 
> On Thursday, June 9, 2011 at 10:14 PM, Justin Edelson wrote:
> 
> > 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 (mailto: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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message