can you try @scr.property sling.servlet.resourceTypes =
"sling/servlet/errorhandler/default"
 ?



On Thu, Jul 28, 2011 at 4:08 PM, Bethoju, Praveen <[email protected]>wrote:

> Hi -
>
> I'd like to create a custom error handler that will handle exceptions
> thrown
> from scripts (at a specific path... ex: /content/api/*) and I want
> errors/exceptions from all other servlets/scripts to be handled in the
> default way (when no custom error handlers are set) using
> DefaultErrorHandlerServlet.
>
> For this purpose, I created a Servlet and mapped it to
> "/apps/sling/servlet/errorhandler/default"
>
> /**
>  *
>  * @scr.component metatype="no" immediate="true"
>  * @scr.service interface="javax.servlet.Servlet"
>  *
>  * This is the custom error handler servlet
>  *
>  * @scr.property name="sling.servlet.paths"
> value="/apps/sling/servlet/errorhandler/default"
>  * @scr.property name="sling.servlet.prefix" value="0"
>  *
>  *
>  */
> public class CustomExceptionHandlerServlet extends GenericServlet {
>
>    /**
>     * @scr.reference policy="static"
>     */
>    protected DefaultErrorHandlerServlet theDefaultErrorHandlerServlet;
>
>
>     @Override
>    public void service(ServletRequest request, ServletResponse response)
> throws IOException {
>
>        SlingHttpServletRequest slingRequest = (SlingHttpServletRequest)
> request;
>        SlingHttpServletResponse slingResponse = (SlingHttpServletResponse)
> response;
>
>        String resourcePath =
> request.getRequestPathInfo().getResourcePath();
>        if(resourcePath.contains("/content/api"))
>        {
>            // perform custom processing.
>        }
>        else
>        {
>            // Somehow forward to the default error handler servlet
>            // or call the default error handler servlet, may be this way ?
>            theDefaultErrorHandlerServlet.service(request, response);
>
>        }
>
>     }
>
> }
>
>
> I have two questions:
>
> 1. In Felix, I see that there's an active component called - "
>
> org.apache.sling.servlets.resolver.internal.defaults.DefaultErrorHandlerServ
> let" available. So, I've added a reference to it from my
> CustomExceptionHandlerServlet class. But for some reason, this dependency
> is
> "unsatisfied". Not sure if I am not doing this wiring correctly. Please
> advise.
>
> 2. If I can't wire the DefaultErrorHandlerServlet as in #1 or if its not
> the
> approach to take, is there a way to forward processing of the error to the
> default error handler servlet?
>
> Thanks
> Praveen
>
>
>
>
>
> **
> This e-mail message is intended only for the designated recipient(s) named
> above. The information contained in this e-mail and any attachments may be
> confidential or legally privileged. If you are not the intended recipient,
> you may not review, retain, copy, redistribute or use this e-mail or any
> attachment for any purpose, or disclose all or any part of its contents.  If
> you have received this e-mail in error, please immediately notify the sender
> by reply e-mail and permanently delete this e-mail and any attachments from
> your computer system.
>

Reply via email to