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

  • SEARCH
  • Home
  • 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 6020275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:32:40+00:00 2026-05-23T03:32:40+00:00

I want to create a jsp login filter. The filter should: intercept requests to

  • 0

I want to create a jsp login filter.

The filter should:

  • intercept requests to any page; verify whether the request is part of a logged-session
  • if the session is not logged, redirect the client to a login page
  • if the requested page is the login page, don’t redirect, otherwise it will loop

thanks in advance

  • 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-23T03:32:40+00:00Added an answer on May 23, 2026 at 3:32 am

    The filter’s implementation scheme is outlined (no code; I’m assuming that you know that Servlet API, which is a prerequisite).

    intercept requests to any page; verify whether the request is part of a logged-session

    You ought to be creating the servlet filter, and map it against /*, so that all requests to the application will be intercepted by this filter. Tracking of authenticated users is assumed to be done using a Session attribute. You can extract the session from the HttpServletRequest object within the filter, and extract the attribute using the getAttribute() method.

    if the session is not logged, redirect the client to a login page

    If the session or the attribute does not exist, or the attribute is false, then you’ll need to redirect the user to the login page, using the sendRedirect() method on the HttpServletResponse object.

    if the requested page is the login page, don’t redirect, otherwise it will loop

    You can determine whether the request is to the login page using the getServletPath() method on the HttpServletRequest object. But this is unnecessary if you do the following:

    • put the login page and other “public” content in the document root directory, i.e. in the /ApplicationContext/ directory*.
    • put the protected content (including all servlet mappings) in the /ApplicationContext/protected directory.
    • Map the filter only to /protected instead of /*. The filter will therefore intercept requests only to protected resources. Be careful when you map any resource to a different path.

    * The ApplicationContext is your application’s context path. If your web site is at http://example.com/App then the context is usually App. Your login page should therefore be http://example.com/App/login.jsp, while a protected page would be accessed as http://example.com/App/protected/secret.jsp

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

Sidebar

Related Questions

I want to create a login page using Servlet & JSP. I ve created
I want to create a JSP page or servlet that will work in 2
I want to create a Thread safe JSP page. It is possible in Servlet
I want to create a client side mail creator web page. I know the
hi all i just want to create a simple jsp tag such as :
I'm doing one litle project with JSP for topic Library. I want to create
I'm using http://example.com/area.jsp?id=1 and want create a mapping path http://example.com/newyork mapping to /area.jsp?id=1 How
I'm practising a bit on JSP and want to create a simple formular field.
I want create a drop shadow around the canvas component in flex. Technically speaking
I want to create a Java application bundle for Mac without using Mac. According

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.