Announcement Announcement Module
Collapse
No announcement yet.
Spring AOP + Jsp Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring AOP + Jsp

    Hi

    I have a strange question.

    Suppose you need to execute code really at the end of server interaction. So, if i use jsp, i need to execute it AFTER the rendering of the page.

    There is a way to execute it?

    i tried after this pointcut

    @Pointcut("@annotation(org.springframework.web.bin d.annotation.RequestMapping)")

    but it leave me just after the "return ModelAndView". I need to get the very end of the server session.

    Maybe it's absurd, but there is a way? Thanks anticipately

  • #2
    Why?! But that is another question.

    Depending on what you need/want you could either write a HandlerInterceptor and implement the afterCompletion method (this is executed after rendering). If you really want to be sure you write a ServletRequestListener which will be executed before the request is handled and when the request is over.

    Comment


    • #3
      Originally posted by Marten Deinum View Post
      Why?! But that is another question.

      Depending on what you need/want you could either write a HandlerInterceptor and implement the afterCompletion method (this is executed after rendering). If you really want to be sure you write a ServletRequestListener which will be executed before the request is handled and when the request is over.
      thank you, i implemented a ServletRequestListener. On the bad side, it lister for EVERY servlet, not only the @RequestMapping invoked servlet. Only for curiosity: afterCompletion is related only to the @RequestMapping annotated method? thanks

      Comment


      • #4
        I suggest a read of the reference guide, the section about HandlerInterceptors, that explains each method in detail and what the use of it is.

        Comment


        • #5
          Sorry, i forgot to mention why: because i want to force closing all the database session, related to the running thread, that could possibly be not closed due to errors etc

          Comment


          • #6
            To answer the why, that is why spring has transaction management etc. build in, simply use that instead of (re)inventing your own.

            Comment

            Working...
            X