Announcement Announcement Module
No announcement yet.
all pages in my web application need certain data Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • all pages in my web application need certain data

    Hi there,

    I have a web application, that has certain data that every page needs. ie. Username, a dynmamically created menu, etc. I was wondering if AOP is the solution to this, so I don't have to have code put in every single controller in my application.

    Any help, advice, resources you can direct me to would be greatly appretiated.


  • #2
    I do this in a HandlerInterceptor, in the postHandle() method.

    Something like:
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView mnv) {
        if (!(mnv.getView() instanceof RedirectView)) {
            mnv.getModel().put("name", object):


    • #3
      AOP can do this but you can use also a customized solution like SiteMesh (or Jakarta Tiles). In our application we have dynamical pages which contain a common skeleton but have to be 'decorated' differently based on some factors (like the user properties).
      I don't know your requirements but give it try - it may save you some trouble .