how to add the servlet api to my pom.xml how to add the servlet api to my pom.xml java java

how to add the servlet api to my pom.xml


I believe most web/app servers come bundled with a version of the servlet api, so you won't want to bundle the api in your .war file. You will need to find out which version is included with your server, then you can use

<dependency>    <groupId>javax.servlet</groupId>    <artifactId>servlet-api</artifactId>    <version>${servlet-api-version}</version>    <scope>provided</scope></dependency>

replacing servlet-api-version with your version. You will want to specify the "provided" scope so the api.jar isn't included in your war file.


    <dependency>        <groupId>javax.servlet</groupId>        <artifactId>servlet-api</artifactId>        <version>2.5</version>        <scope>provided</scope>    </dependency>


For servlet-api 3.1.0, here is the declaration :

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