In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.