HttpSessionBindingListener interface should be implemented by classes that may be bound into sessions as attributes and if they want to know when they were bound. When an object which implements this interface is bound to a session or unbound from the session, the container will call its valueBound and valueUnbound methods respectively. Since the interface is added by the attributes that are added to the session themselves and cannot listen to any other attributes, you don’t have to mention it in the web.xml file or have the @WebListener annotation. [node:read-more:link]
If you need to extend the functionality of request or response objects, there are wrapper classes that can wrap around current request or response. The wrapper classes implements the required interfaces so that we can pass it to any place that expects those interface implementations. These wrappers will simply delegate the calls to the default container implementation of the request and response interfaces. [node:read-more:link]
When a request is forwarded or included using the RequestDispatcher mechanism, the container may change the URI paths (request uri, context path, servlet path, path info and query string) in the request object to reflect new path.
This can be demonstrated using a simple example.
First, we will create an util class with a method to print the current values of all these URI path attributes and call it from a normal servlet, included servlet and forwarded servlet.
All calls to other resources in a web application should go through the container. RequestDispatcher is a mechanism provided by the container for that purpose. Container will give us an implementation of the RequestDispatcher interface and we can use it to delegate control to other resources in the application.
This is a personal technical blog where we share our understanding on various concepts and is neither an official page or documentation for the products described here, nor the official views of the companies we work with.
Keywords used in this website are trademarks of their respective owners. This website is not affiliated with Oracle™ and/or any of the JEE frameworks like Spring™, Struts™, Hibernate™ and JSF™.
All contents and materials are provided freely without any warranty or liability and nothing within the site should be considered as professional advice. In any doubt, please ask, and we will try to help you based on our knowledge. Please let us know if you feel anything is not right here (including any copyright violation) and we will act upon it as fast as we can.