Author: cziegeler Date: Wed Jul 13 08:30:02 2011 New Revision: 1145904 URL: http://svn.apache.org/viewvc?rev=1145904&view=rev Log: SLING-2094 : Adding support to call a sling resource for JSP page exception handler <%@ page errorPage ... %>
Added: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingPageException.java (with props) sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/issues/SLING2094Test.java (with props) sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/ sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/custom-error-page.jsp (with props) sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/sling2094.jsp (with props) Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/PageContextImpl.java sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java sling/trunk/launchpad/builder/src/main/bundles/list.xml Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java?rev=1145904&r1=1145903&r2=1145904&view=diff ============================================================================== --- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java (original) +++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java Wed Jul 13 08:30:02 2011 @@ -37,6 +37,8 @@ import org.apache.felix.scr.annotations. import org.apache.felix.scr.annotations.Service; import org.apache.sling.api.SlingConstants; import org.apache.sling.api.SlingException; +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.SlingIOException; import org.apache.sling.api.SlingServletException; import org.apache.sling.api.resource.ResourceResolver; import org.apache.sling.api.scripting.SlingBindings; @@ -159,6 +161,54 @@ public class JspScriptEngineFactory } /** + * Call the error page + * @param bindings + * @param scriptHelper + * @param context + */ + private void callErrorPageJsp(final Bindings bindings, + final SlingScriptHelper scriptHelper, + final ScriptContext context, + final String scriptName) { + final SlingBindings slingBindings = new SlingBindings(); + slingBindings.putAll(bindings); + + ResourceResolver resolver = (ResourceResolver) context.getAttribute(SlingScriptConstants.ATTR_SCRIPT_RESOURCE_RESOLVER, + SlingScriptConstants.SLING_SCOPE); + if ( resolver == null ) { + resolver = scriptHelper.getScript().getScriptResource().getResourceResolver(); + } + final SlingIOProvider io = this.ioProvider; + io.setRequestResourceResolver(resolver); + jspFactoryHandler.incUsage(); + try { + final JspServletWrapperAdapter errorJsp = getJspWrapperAdapter(scriptName); + errorJsp.service(slingBindings); + + // The error page could be inside an include. + final SlingHttpServletRequest request = slingBindings.getRequest(); + final Throwable t = (Throwable)request.getAttribute("javax.servlet.jsp.jspException"); + + final Object newException = request + .getAttribute("javax.servlet.error.exception"); + + // t==null means the attribute was not set. + if ((newException != null) && (newException == t)) { + request.removeAttribute("javax.servlet.error.exception"); + } + + // now clear the error code - to prevent double handling. + request.removeAttribute("javax.servlet.error.status_code"); + request.removeAttribute("javax.servlet.error.request_uri"); + request.removeAttribute("javax.servlet.error.status_code"); + request.removeAttribute("javax.servlet.jsp.jspException"); + } finally { + jspFactoryHandler.decUsage(); + io.resetRequestResourceResolver(); + } + } + + /** * @param scriptHelper * @throws SlingServletException * @throws SlingIOException @@ -187,13 +237,11 @@ public class JspScriptEngineFactory } } - private JspServletWrapperAdapter getJspWrapperAdapter(final SlingScriptHelper scriptHelper) + private JspServletWrapperAdapter getJspWrapperAdapter(final String scriptName) throws SlingException { final JspRuntimeContext rctxt = jspRuntimeContext; - final SlingScript script = scriptHelper.getScript(); - final String scriptName = script.getScriptResource().getPath(); - JspServletWrapperAdapter wrapper = (JspServletWrapperAdapter) rctxt.getWrapper(scriptName); + JspServletWrapperAdapter wrapper = (JspServletWrapperAdapter) rctxt.getWrapper(scriptName); if (wrapper != null) { return wrapper; } @@ -215,11 +263,18 @@ public class JspScriptEngineFactory if (je.getCause() != null) { throw new SlingException(je.getMessage(), je.getCause()); } - throw new SlingException("Cannot create JSP", je); + throw new SlingException("Cannot create JSP: " + scriptName, je); } } } + private JspServletWrapperAdapter getJspWrapperAdapter(final SlingScriptHelper scriptHelper) + throws SlingException { + final SlingScript script = scriptHelper.getScript(); + final String scriptName = script.getScriptResource().getPath(); + return getJspWrapperAdapter(scriptName); + } + // ---------- SCR integration ---------------------------------------------- /** @@ -414,6 +469,8 @@ public class JspScriptEngineFactory // fallback to standard behaviour throw new BetterScriptException(e.getMessage(), e); + } catch (final SlingPageException sje) { + callErrorPageJsp(props, scriptHelper, context, sje.getErrorPage()); } catch (Exception e) { Added: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingPageException.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingPageException.java?rev=1145904&view=auto ============================================================================== --- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingPageException.java (added) +++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingPageException.java Wed Jul 13 08:30:02 2011 @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.scripting.jsp; + +import org.apache.sling.api.SlingException; + +/** + * The <code>SlingPageException</code> is a runtime exception. + * This exception is used to handle the JSP page exception handler + * <code><%@ page errorPage=</code> scenario and forward as a + * runtime exception to be handled at the outermost level. + */ +public class SlingPageException extends SlingException { + + private final String errorPage; + + public SlingPageException(final String errorPage) { + this.errorPage = errorPage; + } + + public String getErrorPage() { + return this.errorPage; + } + +} Propchange: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingPageException.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingPageException.java ------------------------------------------------------------------------------ svn:keywords = author date id revision rev url Propchange: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingPageException.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java?rev=1145904&r1=1145903&r2=1145904&view=diff ============================================================================== --- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java (original) +++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java Wed Jul 13 08:30:02 2011 @@ -27,8 +27,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; -import java.util.Hashtable; import java.util.HashMap; +import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Vector; @@ -610,11 +610,13 @@ class Generator { if (pageInfo.isErrorPage()) { out.printil("Throwable exception = org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.getThrowable(request);"); - out.printil("if (exception != null) {"); + // Removed the following block because of SLING-2094 + // If we leave it in, an error handler will always set the status code to 500! + /* out.printil("if (exception != null) {"); out.pushIndent(); out.printil("response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);"); out.popIndent(); - out.printil("}"); + out.printil("}");*/ } out.printil("ServletContext application = null;"); Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/PageContextImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/PageContextImpl.java?rev=1145904&r1=1145903&r2=1145904&view=diff ============================================================================== --- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/PageContextImpl.java (original) +++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/PageContextImpl.java Wed Jul 13 08:30:02 2011 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -47,7 +47,9 @@ import javax.servlet.jsp.el.ExpressionEv import javax.servlet.jsp.el.VariableResolver; import javax.servlet.jsp.tagext.BodyContent; -import org.apache.sling.scripting.jsp.jasper.Constants; +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; +import org.apache.sling.scripting.jsp.SlingPageException; import org.apache.sling.scripting.jsp.jasper.compiler.Localizer; import org.apache.sling.scripting.jsp.jasper.el.ELContextImpl; import org.apache.sling.scripting.jsp.jasper.el.ExpressionEvaluatorImpl; @@ -59,7 +61,7 @@ import org.apache.sling.scripting.jsp.ja /** * Implementation of the PageContext class from the JSP spec. Also doubles as a * VariableResolver for the EL. - * + * * @author Anil K. Vijendran * @author Larry Cable * @author Hans Bergsten @@ -70,6 +72,8 @@ import org.apache.sling.scripting.jsp.ja */ public class PageContextImpl extends PageContext { + private Log log = LogFactory.getLog(PageContextImpl.class); + private BodyContentImpl[] outs; private int depth; @@ -94,12 +98,12 @@ public class PageContextImpl extends Pag private transient ServletResponse response; private transient HttpSession session; - + private transient ELContextImpl elContext; private boolean isIncluded; - - + + // initial output stream private transient JspWriter out; @@ -135,7 +139,7 @@ public class PageContextImpl extends Pag this.errorPageURL = errorPageURL; this.request = request; this.response = response; - + // initialize application context this.applicationContext = JspApplicationContextImpl.getInstance(context); @@ -571,7 +575,7 @@ public class PageContextImpl extends Pag * Returns the exception associated with this page context, if any. <p/> * Added wrapping for Throwables to avoid ClassCastException: see Bugzilla * 31171 for details. - * + * * @return The Exception associated with this page context, if any. */ public Exception getException() { @@ -685,18 +689,9 @@ public class PageContextImpl extends Pag } final String path = getAbsolutePathRelativeToContext(relativeUrlPath); - String includeUri = (String) request - .getAttribute(Constants.INC_SERVLET_PATH); - if (includeUri != null) - request.removeAttribute(Constants.INC_SERVLET_PATH); - try { - context.getRequestDispatcher(path).forward(request, response); - } finally { - if (includeUri != null) - request.setAttribute(Constants.INC_SERVLET_PATH, includeUri); - } - } + throw new SlingPageException(path); + } public BodyContent pushBody() { return (BodyContent) pushBody(null); @@ -879,7 +874,7 @@ public class PageContextImpl extends Pag * go away once the EL interpreter moves out of JSTL and into its own * project. For now, this is necessary because the standard machinery is too * slow. - * + * * @param expression * The expression to be evaluated * @param expectedType Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java?rev=1145904&r1=1145903&r2=1145904&view=diff ============================================================================== --- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java (original) +++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java Wed Jul 13 08:30:02 2011 @@ -36,6 +36,7 @@ import org.apache.juli.logging.LogFactor import org.apache.sling.api.SlingException; import org.apache.sling.api.scripting.ScriptEvaluationException; import org.apache.sling.commons.classloader.DynamicClassLoader; +import org.apache.sling.scripting.jsp.SlingPageException; import org.apache.sling.scripting.jsp.jasper.JasperException; import org.apache.sling.scripting.jsp.jasper.JspCompilationContext; import org.apache.sling.scripting.jsp.jasper.Options; @@ -394,13 +395,13 @@ public class JspServletWrapper { ex); } return; - } catch (ServletException ex) { + } catch (final ServletException ex) { handleJspException(ex); - } catch (IOException ex) { + } catch (final IOException ex) { handleJspException(ex); - } catch (IllegalStateException ex) { + } catch (final IllegalStateException ex) { handleJspException(ex); - } catch (Exception ex) { + } catch (final Exception ex) { handleJspException(ex); } @@ -438,13 +439,15 @@ public class JspServletWrapper { (HttpServletResponse.SC_SERVICE_UNAVAILABLE, ex.getMessage()); return; - } catch (ServletException ex) { + } catch (final ServletException ex) { handleJspException(ex); - } catch (IOException ex) { + } catch (final IOException ex) { handleJspException(ex); - } catch (IllegalStateException ex) { + } catch (final IllegalStateException ex) { handleJspException(ex); - } catch (Exception ex) { + } catch (final SlingPageException ex) { + throw ex; + }catch (final Exception ex) { handleJspException(ex); } } @@ -491,7 +494,7 @@ public class JspServletWrapper { * @param ex the exception that was the cause of the problem. * @throws a ServletException with more detailed information */ - protected void handleJspException(Exception ex) + protected void handleJspException(final Exception ex) throws ServletException { final Exception jspEx = handleJspExceptionInternal(ex); if ( jspEx instanceof ServletException ) { @@ -503,9 +506,9 @@ public class JspServletWrapper { /** * Returns only a ServletException or a SlingException */ - private Exception handleJspExceptionInternal(Exception ex) + private Exception handleJspExceptionInternal(final Exception ex) throws ServletException { - Throwable realException = ex; + Throwable realException = ex; String exMessage = ""; if (ex instanceof ServletException) { realException = ((ServletException) ex).getRootCause(); Modified: sling/trunk/launchpad/builder/src/main/bundles/list.xml URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/builder/src/main/bundles/list.xml?rev=1145904&r1=1145903&r2=1145904&view=diff ============================================================================== --- sling/trunk/launchpad/builder/src/main/bundles/list.xml (original) +++ sling/trunk/launchpad/builder/src/main/bundles/list.xml Wed Jul 13 08:30:02 2011 @@ -170,7 +170,7 @@ <bundle> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.scripting.jsp</artifactId> - <version>2.0.16</version> + <version>2.0.17-SNAPSHOT</version> </bundle> <bundle> <groupId>org.apache.sling</groupId> Added: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/issues/SLING2094Test.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/issues/SLING2094Test.java?rev=1145904&view=auto ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/issues/SLING2094Test.java (added) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/issues/SLING2094Test.java Wed Jul 13 08:30:02 2011 @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.launchpad.webapp.integrationtest.issues; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.sling.launchpad.webapp.integrationtest.JspTestBase; + +/** Test the SLING-2094 JSP errorpage statement */ +public class SLING2094Test extends JspTestBase { + public final static String TEST_ROOT = "/apps/sling2094"; + private String testNodePath; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + scriptPath = TEST_ROOT; + + testClient.mkdirs(HTTP_BASE_URL, TEST_ROOT); + for(String file : new String[] { "custom-error-page.jsp", "sling2094.jsp" }) { + uploadTestScript("issues/sling2094/" + file, file); + } + + final Map<String, String> props = new HashMap<String, String>(); + props.put(SLING_RESOURCE_TYPE, TEST_ROOT); + testNodePath = testClient.createNode(HTTP_BASE_URL + TEST_ROOT, props); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + testClient.delete(HTTP_BASE_URL + TEST_ROOT); + } + + public void testWithoutError() throws Exception { + final String expected = "All good, no exception"; + final String url = testNodePath + ".html"; + assertContains(getContent(url, CONTENT_TYPE_HTML), expected); + } + + public void testWithError() throws Exception { + final String expected = "witherror selector was specified"; + final String url = testNodePath + ".witherror.html"; + assertContains(getContent(url, CONTENT_TYPE_HTML), expected); + } +} Propchange: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/issues/SLING2094Test.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/issues/SLING2094Test.java ------------------------------------------------------------------------------ svn:keywords = author date id revision rev url Propchange: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/issues/SLING2094Test.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/custom-error-page.jsp URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/custom-error-page.jsp?rev=1145904&view=auto ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/custom-error-page.jsp (added) +++ sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/custom-error-page.jsp Wed Jul 13 08:30:02 2011 @@ -0,0 +1,26 @@ +<!-- +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<%@ page isErrorPage="true" %> + +<h1>Exception Class:</h1> +<%= exception.getClass() %> + +<h2>Message:</h2> +<%= exception.getMessage() %> Propchange: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/custom-error-page.jsp ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/custom-error-page.jsp ------------------------------------------------------------------------------ svn:keywords = Id Propchange: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/custom-error-page.jsp ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/sling2094.jsp URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/sling2094.jsp?rev=1145904&view=auto ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/sling2094.jsp (added) +++ sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/sling2094.jsp Wed Jul 13 08:30:02 2011 @@ -0,0 +1,34 @@ +<!-- +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<%@page + session="false" + errorPage="/apps/sling2094/custom-error-page.jsp" + import="java.util.Arrays, org.apache.sling.api.SlingHttpServletRequest" +%> + +<% +final String SELECTOR = "witherror"; +final SlingHttpServletRequest slingRequest = (SlingHttpServletRequest)request; +if(Arrays.asList(slingRequest.getRequestPathInfo().getSelectors()).contains(SELECTOR)) { + throw new Exception(SELECTOR + " selector was specified"); +} else { + %>All good, no exception<% +} +%> \ No newline at end of file Propchange: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/sling2094.jsp ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/sling2094.jsp ------------------------------------------------------------------------------ svn:keywords = Id Propchange: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/issues/sling2094/sling2094.jsp ------------------------------------------------------------------------------ svn:mime-type = text/plain