code: private Page notFound(final HttpServletResponse response, final SecurityContext securityContext) throws IOException, FrameworkException {
  
  		final List<Page> errorPages = StructrApp.getInstance(securityContext).nodeQuery(Page.class).and(StructrApp.key(Page.class, "showOnErrorCodes"), "404", false).getAsList();
  
  		for (final Page errorPage : errorPages) {
  
  			if (isVisibleForSite(securityContext.getRequest(), errorPage)) {
  
  				response.setStatus(HttpServletResponse.SC_NOT_FOUND);
  				return errorPage;
  			}
  
  		}
  
  		response.sendError(HttpServletResponse.SC_NOT_FOUND);
  
  		return null;
  	}
docs: Handle 404 Not Found
  
  First, search the first page which handles the 404.
  
  If none found, issue the container's 404 error.
  
  @param response
  @param securityContext
  @param renderContext
  @throws IOException
  @throws FrameworkException