Announcement Announcement Module
Collapse
No announcement yet.
Updating HTML body content using Spring interceptors Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Updating HTML body content using Spring interceptors

    Hi,

    I'm using Spring MVC 3.0.5 version and am making use of HandlerInterceptor. I have a controller which point to a particular ModelAndView pointing to the jsp say home.jsp. However in certain cases i need to append some HTML section into the body of the home.jsp.
    I'm planning to override the postHandle method of the Interceptor, where i would need to append the HTML section into the response OutputStream.

    Just wanted to check if this implementation is the right one?

    Thanks.

  • #2
    No it isn't. As nothing has been written also not sure if that is the best approach, writing your own html in general is ill advised. In general I would suggest a templating approach or some conditional logic in your jsp (the first option is preferred as you should avoid too much logic in your jsps).

    Comment


    • #3
      Originally posted by Marten Deinum View Post
      No it isn't. As nothing has been written also not sure if that is the best approach, writing your own html in general is ill advised. In general I would suggest a templating approach or some conditional logic in your jsp (the first option is preferred as you should avoid too much logic in your jsps).
      Thanks for your reply. The problem is the jsp's are not in my control and what we're doing is that we have a sort of a generic controller which gets called to return ModelAndView of different jsp's.
      The use case is that in the home.jsp, on clicking on a link, a pop-up is shown which displays the content which is fetched from another jsp.
      So we're trying to basically mimic the same pop-up behavior on load of the home.jsp, by trying to inject the required html block to the response.

      Comment


      • #4
        You could try a filter and include something in your response (which is also how SiteMesh works) but manipulating jsps in such a way in general I would recommend against it.

        Comment

        Working...
        X