Upon evaluation of the condition, if it fails, I am utilizing a request dispatcher to redirect to another page. The redirection is successful, however, the CSS is not being applied to the new page. What could be causing this issue?
public class RolePrivilegeFilter implements Filter {
List<String> privilege = null;
private static final String notAuthorizedPath = "/home/notAuthorized.jsf";
@Override
public void destroy() {
log.info("filter finish");
}
@Override
public void doFilter(ServletRequest sRequest, ServletResponse sResponse, FilterChain filterChain) throws IOException, ServletException {
String smUser = null;
try {
HttpServletRequest request = (HttpServletRequest) sRequest;
HttpServletResponse response = (HttpServletResponse) sResponse;
HttpSession session = null;
try {
request = (HttpServletRequest) sRequest;
smUser = request.getHeader(EnvironmentBean.SESSION_ATTR_SM_USER);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
if (rolePrivilege == null || rolePrivilege.isEmpty()) {
rolePrivilege = new RolePrivilegeBuilderImpl().rolePrivilege("Smtest2");
privilege filter bean is\t"+rolePrivilege);
log.debug("After rolePrivilege: " + rolePrivilege);
if (rolePrivilege != null && rolePrivilege.size() > 0 ) {
if (session == null) {
session = request.getSession(true);
}
session.setAttribute("privilege", rolePrivilege);
} else {
//This is the page iam redirecting to.
System.out.println("role privilege not authorized page");
RequestDispatcher rd = request.getRequestDispatcher(notAuthorizedPath);
rd.forward(request, response);
return;
}
} catch (Exception e) {
e.printStackTrace();
log.debug("Error in setting session attribute: " + e.getMessage());
}
log.debug("doFilter() finish");
filterChain.doFilter(sRequest, sResponse);
}
@Override
public void init(FilterConfig arg0) throws ServletException {
log.info("filter start");
}
}
Even though the redirection to the new page is successful, the CSS styles, including background images, are not being displayed. Why could this be happening?