The moose likes Servlets and the fly likes Can filters be invoked AFTER servlets? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Can filters be invoked AFTER servlets?" Watch "Can filters be invoked AFTER servlets?" New topic
Author

Can filters be invoked AFTER servlets?

Qand Davaatsedev
Ranch Hand

Joined: Feb 06, 2002
Posts: 36
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?


Qand
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12327
    
    1
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


Java Resources at www.wbrogden.com
Qand Davaatsedev
Ranch Hand

Joined: Feb 06, 2002
Posts: 36
Thank you, Bill.

Everything's clear now
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can filters be invoked AFTER servlets?
 
Similar Threads
Question about Filter trigger sequence
Filter mapping in web.xml
can any body tell about the filter in servlet
Filters
Regarding filter invocation