Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add the servlet api to my pom.xml

How do I add the servlets API to my project's pom.xml

mvnrepository.com has lots of servlet api and similarly named projects, that I don't know which is the right one. Or are all of them ok?

like image 877
flybywire Avatar asked Sep 02 '09 22:09

flybywire


People also ask

Where do I put Servlet API in eclipse?

For adding a jar file, right click on your project -> Build Path -> Configure Build Path -> click on Libraries tab in Java Build Path -> click on Add External JARs button -> select the servlet-api. jar file under tomcat/lib -> ok. Now servlet has been created, Let's write the first servlet code.

What is POM in XML?

A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used by Maven to build the project. It contains default values for most projects.


1 Answers

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.

like image 129
digitaljoel Avatar answered Sep 28 '22 07:09

digitaljoel