Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can filters be invoked AFTER servlets?

 
Qand Davaatsedev
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following is a quote from "Hibernate in Action" book:

<quote>The job of the servlet filter is to close the Session before the
response is sent to the client (and after all views are rendered and actions are executed).</quote>

Is this approach feasible? As I understand, container invokes a filter BEFORE forwarding to a controller servlet. Can filters be invoked AFTER servlets and JSP pages finish their work to commit work and close Hibernate Session?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A filter sees the request BEFORE the servlet is called and the response AFTER the call returns from the servlet so the answer is yes. Take a look at the doFilter method in the javax.servlet.Filter interface.
Bill
 
Qand Davaatsedev
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Bill.

Everything's clear now
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic