There's more...

The init() behavior seems like @PostConstruct, but this last one is executed before init(), so keep it in mind when using both.

The @PostConstruct is executed right after the default constructor.

Be careful when using the destroy() method and avoid holding any memory reference; otherwise, you can mess up with the servlet life cycle and run into memory leaks.

Get Java EE 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.