-2

I need to show software maintenance notification banner on home page using spring MVC and JSP. what is the best approach to do it and how to do it.on the home page I need to show the banner.I already created JSP page for banner.can anyone suggest good approach to show the banner on homepage and how it get to be called once homepage got opened.

kaushik gopu
  • 9
  • 1
  • 3
  • How about `BANNER` ? – Benjamin M Aug 18 '21 at 14:12
  • What did you research already? Please show your efforts described in [ask]. – hc_dev Aug 18 '21 at 14:14
  • Hello Benjamin, sorry I didn't get your answer. I have one banner.jsp page and I need to show this page on home page. PathBasedController returns the path "home" as landing page. after getting home page I need to show banner.jsp . Hope you got it. – kaushik gopu Aug 18 '21 at 14:23
  • Please add some code (JSP) of your "home" page (landing page where to include the maintenance banner) or of the "banner" you want to show. Both are required as [example]. Did you try to add [``](https://stackoverflow.com/questions/9110148/include-another-jsp-file) to your "home.jsp" ? – hc_dev Aug 18 '21 at 14:34

1 Answers1

0

In Spring-MVC you could use and extend the HandlerInterceptor to answer each request with a redirect to your maintenance-banner.jsp.

Add an interceptor to redirect each request

@Override
public void postHandle(HttpServletRequest request,
                       HttpServletResponse response, Object handler,
                       ModelAndView modelAndView) throws Exception { 
    // HttpSession session = request.getSession(); // optional check for a session 
    try {
        response.sendRedirect("maintenance-banner");
        return;
    } catch(Exception e) {
        // some error logging
    }
}

This way you could easily add a check for a date-time-range to only show the banner within the maintenance period.

See also

hc_dev
  • 8,389
  • 1
  • 26
  • 38
  • Hello hc_dev, I will clearly mention the requirements and please suggest me the approach. i)banner.jsp ii)home.jsp. I need to show banner.jsp on home.jsp based on condition (for ex : to show banner on Thursday and Friday). Just a pop kinda banner and user can close it. I need just provide an update that under particular time application will be under maintenance.hope u got my requirement. thanks in advance – kaushik gopu Aug 18 '21 at 15:53