Results 1 to 4 of 4

Thread: Updating HTML body content using Spring interceptors

  1. #1

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    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).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Quote 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.

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •