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 8059117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:34:20+00:00 2026-06-05T09:34:20+00:00

I am creating a simple web application using servlets and JSP. I am implementing

  • 0

I am creating a simple web application using servlets and JSP. I am implementing a Filter which checks if the user has logged in already, literally checks if the user session is alive. If the session is not alive, then the user has to be redirected to the login page (index,jsp)

This is my filter mapping in the web.xml file

 <web-app xmlns...>
  <display-name>FilterTest</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <filter>
    <filter-name>LoginFilter</filter-name>
    <filter-class>LoginFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>LoginFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <servlet>
    <description></description>
    <servlet-name>LoginController</servlet-name>
    <servlet-class>LoginController</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>LoginController</servlet-name>
    <url-pattern>/LoginController</url-pattern>
  </servlet-mapping>
</web-app>

When the user tries to access a different page, then the LoginFilter checks for the session. If the session is alive the user is redirected to the requested page else redirected to index.jsp.

The problem I am facing here is, the LoginFilter checks for the session even when the user is logging in ( request comes from the index.jsp which is the login page).
So what I see here is, When the user logs in, the control goes to the LoginFilter, since the session is not yet created for this user, he is redirected back to login page which is creating a indefinite redirect loop.

I want to exclude the filter checking/session checking if the request is coming from index.jsp.

Is there any way in which I can accomplish this ? Or any way by which I can identify if the requesting page is index.jsp ?

UPDATE: The url when the application starts up is http://servername:port/FilterTest
Here the index.jsp is loaded.

I am validating the login in LoginController servlet which redirects the user to home.jsp (welcome page) if the login was successful.

Thanks..!

  • 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-06-05T09:34:22+00:00Added an answer on June 5, 2026 at 9:34 am

    Skip your Filter check for Login page

    You need to check requestedUrl and see if it doesn’t require Filter (for LoginPage, CSS, Images, JS) then simply do

    chain.doFilter(request, response);  
    

    Pass the init parameter to Filter from web.xml
    from init() create a List<String> urls which doesn’t need filter check
    now in doFilter() check if URL is one of those then simply chain.doFilter(request, response);

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

Sidebar

Related Questions

I am interested in creating a simple web application that will take in user
i am creating simple call filter application which restrict unwanted calls. i use following
i'm creating a very simple (hello World quality) web application using spring mvc 3.0.
I am creating simple blog web application using play framework and i want to
I am creating a simple blog web application using play framework, where there are
I'm creating a web application for work where the user has to enter the
Possible Duplicate: Selecting Random Rows in MySQL I'm creating a simple web application using
I am creating one simple conference application (Java based) and using RESTFull Web Service
When I'm creating a user for my web application, an SMTP email (using ASP.NET's
I'm creating a simple pastebin web application on top of Symfony2, but I can't

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.