Downloading my ServletContextListener in Tomcat 7

New to Tomcat and the launch of Tomcat 7 in the Eclipse environment.

I created a tutorial for creating a class ServletContextListener. My question is, just how do I get this downloaded and running in Tomcat? Can I use annotations? Do i need to edit the xml file?

+3
source share
3 answers

Javadoc to the rescue:

To receive these notification events, the implementation of the class must be declared in the deployment descriptor of the network application annotated by WebListener or registered through one of the addListener defined in ServletContext.

+4
source

As an example, in the web.xml file:

<listener>
    <listener-class>fully qualified class name of your listener class</listener-class>
</listener>
+4
source

When you download Tomcat 7.0 from the Apache Tomcat website, you will get a version containing the sample application. Some features of Servlet 3.0 have source code and customization, such as annotations.

Take a look at these examples - they are useful.

0
source

All Articles