I am trying to use a doFilter and my web.xml page to force users to login to access any "secured" page.
I found an example here and I have implemented it. I am having a small issue though. When I put the filter definition into web.xml the entire website fails to load. I do believe this is because I do not have the proper class path to the java file which contains the filter. I am showing you my web.xml page next to my project explorer. I am hoping you can help me with the class path needed for the
<filter-class> </filter-class>
I am also showing my doFilter method
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
UserBean userBean = (UserBean)((HttpServletRequest)request).getSession().getAttribute("userBean");
if(userBean == null || !userBean.isSuccessfullLogin()){
String contextPath = ((HttpServletRequest)request).getContextPath();
((HttpServletResponse)response).sendRedirect(contextPath + "/index.xhtml");
}
chain.doFilter(request, response);
}
So far the rest of my server works, the website runs but I can not get the filter. Any suggestions are accepted!
Thank you!