Missing javax.servlet.http.Cookie class

Go To StackoverFlow.com


I haven't been using Java extensively hence forget a lot fundamental things. Basically, I am working with a web-dynamic project (using Eclipse IDE with jdk 1.6), and during the build, I get errors that Cookie class and other web related classes cannot be found. What am I missing?

What Jars files do I need to add (and how)?


2009-06-16 14:04
by NoName


Think you need servlet-api.jar

Try here for any jar files you need http://www.java2s.com/Code/Jar/CatalogJar.htm

2009-06-16 14:09
by PaganSensei


Sounds like you are missing servlet-api.jar

You can download it from the Maven repository.

2009-06-16 14:08
by NoName


Servlets are only part of the Enterprise Edition, not of the Standard Edition of Java. So you need the Java Enterprise Edition, AKA Java EE.


2009-06-16 14:08
by sleske


As others have said, you're missing the server api jar.

Having said that, downloading just the servlet api jar and not the server that goes with it means that you can't actually test your code.

In Eclipse, once you're installed a servlet container, such as Sun's Glassfish, Apache Tomcat, or Jetty, you can create a server instance of it so that Eclipse will compile against your server's servlet implementation. Creating a server instance also means that Eclipse's Run on Server command works.

IBM has a slightly outdated guide on Developing Web applications with Tomcat and Eclipse. The entire "Install the Web tools" section can be skipped if you have the Eclipse EE version, as Web Tools are already installed.

2009-06-16 14:23
by Powerlord