Следующий фильтр сервлетов вызывается, но не может дать правильный ответ.Я просто зациклился внутри самого фильтра.Браузер говорит:
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
ExpenseAuthenticationFilter.class
public class ExpenseAuthenticationFilter implements Filter {
public ExpenseAuthenticationFilter() {
// TODO Auto-generated constructor stub
}
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
try
{
HttpSession session = ((HttpServletRequest)request).getSession(false);
if (session == null){
System.out.println("Inside login Filter");
((HttpServletResponse) response).sendRedirect("ExpenseManagementLogin.html");
}
}
catch (IllegalStateException ise){
System.out.println("Session Not Yet Created");
}
chain.doFilter(request, response);
}
public void init(FilterConfig fConfig) throws ServletException {
// TODO Auto-generated method stub
}
}
ExpenseAuthentication.class
public class ExpenseAuthentication implements Filter {
public ExpenseAuthentication() {
// TODO Auto-generated constructor stub
}
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException, IllegalStateException{
try
{
HttpSession session = ((HttpServletRequest) request).getSession(false);
if (session == null ){
System.out.println("Management Filter");
((HttpServletResponse) response).sendRedirect("ExpenseManagementLogin.html");
}
}
catch (IllegalStateException ise){
System.out.println("Session Not Yet Created");
}
chain.doFilter(request, response);
}
public void init(FilterConfig fConfig) throws ServletException {
// TODO Auto-generated method stub
}
}
Web.xml
<filter>
<filter-name>ExpenseAuthentication</filter-name>
<filter-class>com.pricar.hibernate.ExpenseAuthentication</filter-class>
</filter>
<filter-mapping>
<filter-name>ExpenseAuthentication</filter-name>
<url-pattern>*/ExpenseDetailsManagement.html</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>ExpenseAuthenticationFilter</filter-name>
<url-pattern>*/ExpenseManagementLogin.html</url-pattern>
</filter-mapping>
Журнал консоли для "http://localhost:8080/Hibernate/ExpenseDetailsManagement.html" равен
Inside login Filter
Inside login Filter
Inside login Filter
Inside login Filter
Inside login Filter
Inside login Filter
Inside login Filter
Inside login Filter
Inside login Filter
Inside login Filter
Inside login Filter
Inside login Filter
Inside login Filter
Inside login Filter
Inside login Filter
Inside login Filter
Inside login Filter
Inside login Filter
Это нена самом деле идет в ExpenseAuthentication.class, но он идет в ExpenseAuthenticationFilter.class и зацикливается внутри него.
Любые предложения !!
Спасибо!