Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make run a servlet filter?
    primarykey
    data
    text
    <p>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 <code>Servlet class com.pricar.grid.AuthenticationFilter is not a javax.servlet.Servlet</code>. </p> <p>I also cant able to get the proper result.</p> <p>Here my Code: <strong>filter config in web.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt; &lt;!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"&gt; &lt;web-app&gt; &lt;display-name&gt;Staff Management&lt;/display-name&gt; &lt;filter&gt; &lt;filter-name&gt;AuthenticationFilter&lt;/filter-name&gt; &lt;display-name&gt;AuthenticationFilter&lt;/display-name&gt; &lt;description&gt;&lt;/description&gt; &lt;filter-class&gt;com.pricar.grid.AuthenticationFilter&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;AuthenticationFilter&lt;/filter-name&gt; &lt;url-pattern&gt;/StaffManagementSystem/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; &lt;servlet&gt; &lt;servlet-name&gt;dwr-invoker&lt;/servlet-name&gt; &lt;display-name&gt;DWR Servlet&lt;/display-name&gt; &lt;description&gt;Direct Web Remoter Servlet&lt;/description&gt; &lt;servlet-class&gt;uk.ltd.getahead.dwr.DWRServlet&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;debug&lt;/param-name&gt; &lt;param-value&gt;true&lt;/param-value&gt; &lt;/init-param&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;dwr-invoker&lt;/servlet-name&gt; &lt;url-pattern&gt;/dwr/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;welcome-file-list&gt; &lt;welcome-file&gt;UserLogin.html&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;/web-app&gt; </code></pre> <p><strong>The Filter code is:</strong></p> <pre><code>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 } } </code></pre> <p>The URL i am trying to test is <a href="http://localhost:8080/StaffManagementSystem/EmployeeManagement.html" rel="nofollow noreferrer">http://localhost:8080/StaffManagementSystem/EmployeeManagement.html</a></p> <p>i am using jetty as a server.</p> <p><strong>Any suggestions would be appreciative!!! Thanks in Advance!!</strong></p> <hr> <p><strong>Final Update:</strong></p> <p>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. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload