Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1070583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:35:05+00:00 2026-05-16T20:35:05+00:00

For my web application, i have created login page. To block the access to

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:35:06+00:00Added an answer on May 16, 2026 at 8:35 pm

    If your URL is http://localhost:8080/StaffManagementSystem/EmployeeManagement.html don’t you mean to use this pattern for your filter mapping :

        <url-pattern>/StaffManagementSystem/*</url-pattern>
    

    And you may have an error in your web.xml somewhere else. Didn’t you use your Filter as a Servlet anywhere in your configuration ?


    Your doFilter() method does a chain.doFilter (request, response); before even checking the values. You should remove this line too.


    At the end your doFilter() does a redirect anyway. You should remove the entire else part.


    And implementing Filter means that your must write the method :

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    

    (Not one with HttpServlet******)


    You should avoid to use System.out in a web application. Instead choose loggers and check the logs of your servlet container.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a web application in which certain pages are login-protected. I have created
I have created a login application in jsp/servlet in my web project and I
I have a login page in a web application project: <h:form> <h:messages /> <h:inputText
I have a web application that begins with a login page. During the verification
I want my web application to contain only one session created at login. But
I have created a Web Application in asp.net 2.0. which is working fine on
We have created a web application, using ASP.NET, that allows users to upload documents
I have created a web application using Visualstudio 2008 using C# on my computer.
I have created a web application with a Silverlight project embedded in it, using
i have created an mvc3 web application that uses forms based authentication. one part

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.