O'Reilly logo

Servlet & JSP: A Tutorial, Second Edition by Budi Kurniawan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 22

Dynamic Registration and Servlet Container Initializers

Dynamic registration and the servlet container initializer were added to Servlet 3.0. The former is used for installing new web objects (servlets, filters, listeners) without reloading the application. The latter is especially useful for framework developers.

This chapter discusses both features and presents examples.

Dynamic Registration

To make dynamic registration possible, the following methods were added to the ServletContext interface to dynamically create a web object.

<T extends Filter> createFilter(java.lang.Class<T> clazz)
<T extends java.util.EventListener> createListener(
        java.lang.Class<T> clazz)
<T extends Servlet> createServlet(java.lang.Class<T>  ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required