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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:24:51+00:00 2026-06-12T17:24:51+00:00

I have a Spring MVC webapp that uses Spring Security. I want to add

  • 0

I have a Spring MVC webapp that uses Spring Security. I want to add “Store is closed” functionality – i.e. if I set the store to be closed, regardless of where the user tries to navigate on my site they will end up on the page saying “Store is closed”.

I have implemented a Security Filter as follows (and can wire it in fine):

public class ClosedFilter extends OncePerRequestFilter {

@Override
protected void doFilterInternal(HttpServletRequest req,
        HttpServletResponse response,
        FilterChain chain) throws ServletException, IOException {

    if(storeIsClosed()) {
        //do something useful here
    }else {
        chain.doFilter(req, response);
            }

}

}

But am unsure what to put in the “//do something useful here” bit. I have tried:

throw new StoreIsClosedException();  //extends RuntimeException

but I can’t then map my exception to my view. I also tried

response.redirect("myClosedView");

with no luck. What I want is something conceptually like:

   return new ModelAndView("closed");

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-12T17:24:52+00:00Added an answer on June 12, 2026 at 5:24 pm

    I ended up with a solution, I changed my filter to:

    public class ClosedFilter extends OncePerRequestFilter {
    
    @Override
    protected void doFilterInternal(HttpServletRequest req,
            HttpServletResponse response,
            FilterChain chain) throws ServletException, IOException {
    
        if (isClosed()) {
            final String path = req.getContextPath()+"/closed.do";
            if(!path.equals(req.getRequestURI())) {
                response.sendRedirect(path);
                return;
            }
        }
        chain.doFilter(req, response);
    }
    
    
    }
    

    and then added this to my security.xml

    <intercept-url pattern="/closed.do*" access="permitAll"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a spring web app that uses Hibernate and Velocity. It's an MVC
I have a small Spring MVC webapp (which embeds ActiveMQ) that is designed to
I have a Java/Spring MVC/JSP/JSTL webapp. We have a designer that gave us some
i have written a small webapp using spring-security and spring-mvc with an annotation based
I have a webapp that uses SpringMVC DispatcherServlet to load a WebApplicationContext. The Spring
I have to implement validations for a web app that uses Spring MVC 3.
I'm using Spring Roo, and Spring MVC. I have Set up Spring Security to
I have a Spring MVC application which uses FreeMarker as View technology (But maybe
I have a spring mvc application that I have broken up into separate maven
I have a localized spring mvc based web application, that has an externalized messages

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.