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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:35:19+00:00 2026-06-06T14:35:19+00:00

I am using Spring security feature in my application, but I found out that

  • 0

I am using Spring security feature in my application, but I found out that when the session expired, all the request ajax return the page login.jsp(not redirect, in http response, it puts all the html content) which is the login page of my webapp.
I used a lot of ajax request in my app and the goal is return certain error code like 510 instead of the login page.

<session-management session-authentication-strategy-ref="example" /> 

without invalid-session-url
I tried to make invalid-session-url = “”, doesn’t work.
Many 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-06T14:35:20+00:00Added an answer on June 6, 2026 at 2:35 pm

    Use custom AuthenticationEntryPoint:

    package com.example.spring.security
    // imports here
    
    public class AjaxAwareAuthenticationEntryPoint
         extends LoginUrlAuthenticationEntryPoint {
    
      public AjaxAwareAuthenticationEntryPoint(final String loginFormUrl) {
        super(loginFormUrl);
      }
    
      @Override
      public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException)
          throws IOException, ServletException {
    
        if ("XMLHttpRequest".equals(request.getHeader("X-Requested-With"))) {
          response.sendError(403, "Forbidden");
        } else {
          super.commence(request, response, authException);
        }
      }
    }
    

    Define a bean and use it as entry-point-ref in <http> element:

    <http entry-point-ref="authenticationEntryPoint">
      <!-- more configuration here -->
    </http>
    
    <bean id="authenticationEntryPoint"
       class="com.example.spring.security.AjaxAwareAuthenticationEntryPoint">
     <constructor-arg value="/login.jsp"/>
    </bean>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using spring security, java in application. When the session gets expired, I
I'm using Spring Security 3.0.2 form based authentication. But I can't figure out how
My web application is using Spring Security but it returning a BadCredentialsException when processing
Using Spring Security 3.1.0, I cannot seem to get the concurrent session control feature
I'm using Spring, Spring Security, BlazeDS, Flex and spring-flex. I know that I can
I'm having trouble using Spring Security successfully in my Grails application. I installed the
I'm using Spring Security which works great to make sure that a user has
We are using Spring Security 3. We have a custom implementation of PermissionEvaluator that
I'm working on an application using Spring security. The application is extensible and I
hi I have a j2ee application using Spring webflow and Spring Security. I want

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.