35

In order to write servlets code I need servlet-api.jar. Where do i get servlet-api.jar from ?

oneiros
  • 3,527
  • 12
  • 44
  • 71
  • 3
    Related (and very important): http://stackoverflow.com/questions/4076601/how-do-i-import-the-javax-servlet-api-in-my-eclipse-project – BalusC Dec 15 '11 at 15:07

4 Answers4

29

Make sure that you're using the same Servlet API specification that your Web container supports. Refer to this chart if you're using Tomcat: http://tomcat.apache.org/whichversion.html

The Web container that you use will definitely have the API jars you require.

Tomcat 6 for example has it in apache-tomcat-6.0.26/lib/servlet-api.jar

Oleg Mikheev
  • 17,186
  • 14
  • 73
  • 95
  • 7
    For those with Tomcat 7, you'll probably find the lib directory in /usr/share/tomcat7/lib – jsaven Jan 15 '13 at 10:38
  • How do i know what Servlet API specification my Web container supports? Also: what's a Web container, and where do i get one? – Ian Boyd Jun 28 '22 at 15:21
13

Grab it from here

Just choose required version and click 'Binary'. e.g direct link to version 2.5

yatskevich
  • 2,085
  • 16
  • 25
  • This should get the checkmark if you just want the jar, no muss no fuss. Awesome! –  Jan 14 '14 at 01:21
4

You may want to consider using Java EE, which includes the javax.servlet.* packages. If you require a specific version of the servlet api, for instance to target a specific web application server, you will probably want the Java EE version which matches, see this version table.

James Clark
  • 1,765
  • 13
  • 17
2

You can find a recent servlet-api.jar in Tomcat 6 or 7 lib directory. If you don't have Tomcat on your machine, download the binary distribution of version 6 or 7 from http://tomcat.apache.org/download-70.cgi

Babatunde Adeyemi
  • 14,360
  • 4
  • 34
  • 26