In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
HttpSessionListener- creation and destruction
/ / @ WebListener servlet3.0 supports annotations public class HttpSessionListenerDemo implements HttpSessionListener {@ Override public void sessionCreated (HttpSessionEvent httpSessionEvent) {HttpSession session = httpSessionEvent.getSession (); ServletContext servletContext = session.getServletContext (); / / undo} @ Override public void sessionDestroyed (HttpSessionEvent httpSessionEvent) {/ / undo}}
Stunning and activation of HttpSessionActivationListener-
/ / @ WebListener servlet3.0 supports annotations public class HttpSessionActivationListenerDemo implements HttpSessionActivationListener {@ Override public void sessionWillPassivate (HttpSessionEvent httpSessionEvent) {} @ Override public void sessionDidActivate (HttpSessionEvent httpSessionEvent) {}}
HttpSessionAttributeListener- attribute value change
/ / @ WebListener servlet3.0 supports annotations public class HttpSessionAttributeListenerDemo implements HttpSessionAttributeListener {@ Override public void attributeAdded (HttpSessionBindingEvent httpSessionBindingEvent) {} @ Override public void attributeRemoved (HttpSessionBindingEvent httpSessionBindingEvent) {} @ Override public void attributeReplaced (HttpSessionBindingEvent httpSessionBindingEvent) {}}
Delete or increase the value of the HttpSessionBindingListener- attribute
/ / @ WebListener servlet3.0 supports annotations public class HttpSessionBindingListenerDemo implements HttpSessionBindingListener {@ Override public void valueBound (HttpSessionBindingEvent httpSessionBindingEvent) {} @ Override public void valueUnbound (HttpSessionBindingEvent httpSessionBindingEvent) {}}
Design architecture
The design pattern of the listener is the observer pattern.
Event source: HttpSession
Events: subclasses of EventObject, such as HttpSessionEvent and HttpSessionBindingEvent
Event listener: a subclass of EventListener.
The observed is the servlet container. The observer is our listener. Usually an actual observer is introduced into a self-implemented listener to handle events.
Note: the loading order of web.xml is: [Context-Param]-> [Listener]-> [Filter]-> [Servlet], and the order of actual program calls between the same type is based on the order of the corresponding Mapping.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.