Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Spring
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Spring
Custom logout handler
Pranav Sharma
Ranch Hand
Posts: 261
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I need to call a sproc when a user logs out. How do I go about adding a custom logout handler to standard spring logout handling.
Thanks
Bill Gorder
Bartender
Posts: 1682
7
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
By 'Standard spring logout handling' I assume you are using Spring Security.
The answer is write your own custom LogoutSuccessHandler
<security:logout logout-url="/logout" success-handler-ref="myCustomLogoutSuccessHandler" />
@Component public class MyCustomLogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler { @Override public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { if (authentication != null) { // call sproc } setDefaultTargetUrl("/login"); //below does the 'standard' spring logout handling super.onLogoutSuccess(request, response, authentication); } }
[
How To Ask Questions
][
Read before you PM me
]
Pranav Sharma
Ranch Hand
Posts: 261
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks Bill.
Any suggestions to where I could read more about this. I searched through the Spring documentation, did not find info about custom handlers. Thanks.
Bill Gorder
Bartender
Posts: 1682
7
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
There is a brief mention of it in the reference documentation
HERE
Otherwise take a look at API
http://static.springsource.org/spring-security/site/docs/3.1.x/apidocs/org/springframework/security/web/authentication/logout/LogoutSuccessHandler.html
or alternatively you could use
http://static.springsource.org/spring-security/site/docs/3.1.x/apidocs/org/springframework/security/web/authentication/logout/LogoutHandler.html
[
How To Ask Questions
][
Read before you PM me
]
Pranav Sharma
Ranch Hand
Posts: 261
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thank you.
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Strange tomcat 8 and java 8 behavior during logout
j2ee application instance in tomcat container
How can i invalidate user from session when he/she is not logged out successfully
Spring Security LogoutFilter
How to correctly handle a browser 'back'
More...