Skip to content

Maven

We can use Maven to manage our Java dependencies. * HttpServlet is not a core Java library, so we have to get its class files.

Convert the project to a Maven project by right-clicking the project name and selecting Configure->Convert to Maven Project.

Configure, Convert to Maven Project

Choose the defaults and select Finish.

This creates the pom.xml file. Open it and select the lower pom.xml tab to view the source of the file.

After the closing </build> add the servlet API dependencies.

<dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
    </dependency>
</dependencies>

You now have the code necessary to create servlets.

Drill

MyHelloWorld

Convert your project to use Maven, and add servlet api dependencies to the pom.xml.


Prev -- Up -- Next