In my JSF application, I would like to implement a web filter to change the requested view in function of the used device (I use spring-mobile device resolver).
I have this in my filter:
String requestURI = request.getRequestURI();
Device device = DeviceUtils.getCurrentDevice(request);
if (!requestURI.contains("/mobile") && device.isMobile()) {
String newUri = requestURI.replace("/contextroot/faces/html/", "/contextroot/faces/html/mobile/");
request.getRequestDispatcher(newUri).forward(request, response);
}
else {
filterChain.doFilter(request, response);
}
But I get an exception
/contextroot/faces/html/mobile/consult/consult.xhtml Not Found in ExternalContext as a Resource
What am I doing wrong?