fuzzy28 fuzzy28 - 1 month ago 5
Java Question

Difference between javax.servlet-api.jar vs servlet-api.jar

In my maven repository under groupId

javax.servlet
i have these two separate artifacts for servlets. I am confused which one should i use to build a simple servlet application? What's the difference between these two artifacts?

dds dds
Answer

You need to add

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

to your project. The version you need may differ - it depends on your servlet container, e.g. Tomcat.

<scope>provided</scope> because you don't need it in runtime, it's already in your servlet container.