Web containers like Tomcat already include their own version of the Servlet API. If you bundle your own, it leads to or LinkageErrors because the JVM will see two different versions of the same class. Always mark the dependency as "provided" in your build tool, meaning it’s needed for compilation but should be supplied by the server at runtime. How to Add servlet-api.jar to Your IDE In Eclipse:
Click and navigate to your downloaded servlet-api.jar (or the one in your Tomcat/lib folder). Click Apply and Close . In IntelliJ IDEA: Go to File > Project Structure . Select Modules > Dependencies . Click the + icon > JARs or Directories . Select your JAR and ensure the scope is set to Provided . Choosing the Right Version Servlet Version Java EE / Jakarta EE Version Minimum JDK Main Feature Servlet 6.0 Jakarta EE 10 Fully uses jakarta.* package Servlet 5.0 Jakarta EE 9 Transition to jakarta.* namespace Servlet 4.0 HTTP/2 Support Servlet 3.1 Non-blocking I/O servlet-api.jar download
For modern projects using Maven or Gradle, you should never download the JAR manually. Instead, you pull it from the Maven Central Repository. Web containers like Tomcat already include their own
If you require a standalone JAR for a legacy project, sites like Jar-Download.com or MVNRepository allow you to download specific versions (2.5, 3.0, 3.1, 4.0) directly to your machine. Important: Why You Should Use "Provided" Scope How to Add servlet-api