Hi,
For my web application, i have created login page. To block the access to the other pages i setup a filter. But while running the web app, it gives Servlet class com.pricar.grid.AuthenticationFilter is not a javax.servlet.Servlet
.
I also cant able to get the proper result.
Here my Code: filter config in web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Staff Management</display-name>
<filter>
<filter-name>AuthenticationFilter</filter-name>
<display-name>AuthenticationFilter</display-name>
<description></description>
<filter-class>com.pricar.grid.AuthenticationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AuthenticationFilter</filter-name>
<url-pattern>/StaffManagementSystem/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<display-name>DWR Servlet</display-name>
<description>Direct Web Remoter Servlet</description>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>UserLogin.html</welcome-file>
</welcome-file-list>
</web-app>
The Filter code is:
package com.pricar.grid;
public class AuthenticationFilter implements Filter {
public AuthenticationFilter() {
// 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 {
WebContext ctx = WebContextFactory.get();
HttpServletRequest req = ctx.getHttpServletRequest();
HttpSession session = req.getSession(false);
String name = (String) session.getAttribute("userName");
System.out.print ("Within Simple Filter ... ");
System.out.println ("Filtering the Request ...");
System.out.print ("Within Simple Filter ... ");
System.out.println ("Filtering the Response ...");
if ( name == null ){
//I have to redirect to the person to index page.
((HttpServletResponse) response).sendRedirect("index.html");
}
chain.doFilter(request, response);
}
public void init(FilterConfig fConfig) throws ServletException {
// TODO Auto-generated method stub
}
}
The URL i am trying to test is http://localhost:8080/StaffManagementSystem/EmployeeManagement.html
i am using jetty as a server.
Any suggestions would be appreciative!!! Thanks in Advance!!
Final Update:
All the changes that mentioned, were done. Its getting compiled. I cant even able to get the "sysout" output in my console. Its simply passing the URL.