Oh one question: if I'm implementing OptingServlet, what should be path or selectors it has to listen to behave like /apps/sling/servlet/errorhandler/Throwable.jsp (handles all uncaught Throwables)??
On Mon, Dec 6, 2010 at 7:26 AM, sam lee <[email protected]> wrote: > Ah that's better! I didn't think of using OptingServlet. I ended up with > porting DefaultErrorHandlerServlet to errorHandler.jsp and put it on > /apps/sling/servlet/errorhandler and in Throwable.jsp, I did something > like: > > <%if (.........){%> > //process to my liking > <%} else {%> > <cq:include > script="/apps/sling/servlet/errorhandler/errorHandler.jsp"/> > <%}%> > > > Thanks. > Sam > > > On Mon, Dec 6, 2010 at 2:56 AM, Felix Meschberger <[email protected]>wrote: > >> Hi, >> >> Am Freitag, den 03.12.2010, 17:36 -0500 schrieb sam lee: >> > I want to handle uncaught exceptions only some times. >> > >> > According to this page: >> > http://sling.apache.org/site/errorhandling.html >> > >> > I created /apps/sling/servlet/errorhandler/Throwable.jsp >> > >> > But, only when some conditions are met, I want to use custom >> Throwable.jsp. >> > Other times, I want sling to use >> > >> > >> org.apache.sling.servlets.resolver.internal.defaults.DefaultErrorHandlerServlet. >> > >> > Since I am overriding Throwable.jsp, how can I call >> > DefaultErrorHandlerServlet inside Throwable.jsp? >> > >> > in Throwable.jsp: >> > >> > if (shouldUseCustomTemplate()) { >> > //do my thing >> > } else { >> > new DefaultErrorHandlerServlet.doGet(request, response); >> > } >> >> Instead of writing a JSP you could register a Servlet service with a >> servlet object implementing the OptingServlet interface. Upon the >> accepts method call you might decide whether to handle the error >> condition or not. >> >> Thus if the servlet decides to handle, it is called. If the servlet >> decides not handle the condition, another servlet is looked up. >> >> Hope this helps. >> >> Regards >> Felix >> >> >> >
