Implementing 404 error handler.
404 error handler is implemented by overlaying the 404 from /libs/sling/servlet/errorhandler/404.jsp but changes 404.jsp to 404.html. And Java class to handle the request. on Dispatcher enabled below two flags
<IfModule disp_apache2.c>
# Enabled to allow rewrites to take affect and not be ignored by the dispatcher module
DispatcherUseProcessedURL On
# Default setting to allow all errors to come from the aem instance
DispatcherPassError 1
</IfModule>
Java class have -
import com.adobe.cq.sightly.WCMUsePojo;
public class PageNotFound extends WCMUsePojo {
@Override
public void activate() throws Exception {
getResponse().setStatus(404);
getResponse().setContentType("text/html");
getResponse().setHeader("Dispatcher", "no-cache");
getResponse().setHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0");
getResponse().setHeader("Pragma", "no-cache");
}
}
And html have -
<sly data-sly-use.pageNotFound="com.aem.core.errorHandler.PageNotFound"></sly>
<sly data-sly-resource="${'/content/aem/us/en/404/jcr:content' @ wcmmode='disabled'}"></sly>
This implementation works good on local but on qa environment it is going to default.jsp under errorhandler.
Actula requirement is page shouldn’t redirect to 404.html but content is served from that page.
Can someone let me know the root cause for this issue?