SlingHttpServletResponse setStatus and dispatcher forward not working for 500 on cloud | Adobe Higher Education
Skip to main content
Level 2
March 29, 2023
解決済み

SlingHttpServletResponse setStatus and dispatcher forward not working for 500 on cloud

  • March 29, 2023
  • 1 の返信
  • 762 ビュー

From sling filter, in case of an error we are trying to send back the response code to the browser using SlingHttpServletResponse setStatus method and then forward to error page using RequestDispatcher. Please see the code below for the same -

slingResponse.setStatus(errorCode); RequestDispatcher dispatch = slingRequest.getRequestDispatcher(redirectURLForErrorPage); dispatch.forward(slingRequest, slingResponse);

This is working fine if the errorCode is in series of 400 i.e. 401, 404 etc. but its not working for errorCode 500.
If the errorCode is 500, it sends back the 500 error code to browser but does not forward to the error page.

The same code works fine on local for both 400s and 500s error codes but does not work on the cloud environments.

We have tried using dispatch.include and setting larger buffer size, as suggested in some other posts in this community, but that didnt work.

Is this something that is blocked by some dispatcher config in cloud or some other issue, please suggest.

Thanks in advance.

このトピックへの返信は締め切られました。
ベストアンサー joerghoh

You should not need to do this manually. The Sling Main Servlet catches all exceptions and forwards them to a configured error handler. See https://sling.apache.org/documentation/the-sling-engine/errorhandling.html (especially the section "Default Handlers").

 

1 の返信

joerghoh
Adobe Employee
joerghohAdobe Employee回答
Adobe Employee
March 31, 2023

You should not need to do this manually. The Sling Main Servlet catches all exceptions and forwards them to a configured error handler. See https://sling.apache.org/documentation/the-sling-engine/errorhandling.html (especially the section "Default Handlers").