chinna_82
chinna_82

Reputation: 6403

The import javax.servlet.annotation cannot be resolved

Im trying to create servlet for my project but encountered The import javax.servlet.annotation cannot be resolved. I've already added javax.servlet and servlet-api.jar from tomcat. Please refer the image below. Servlet

Upvotes: 12

Views: 39076

Answers (4)

user2886971
user2886971

Reputation: 71

Ensure You download the jar javax.servlet-api-3.0.1.jar from the link http://mvnrepository.com/artifact/javax.servlet/javax.servlet-api/3.0.1

Upvotes: 7

Abhinai
Abhinai

Reputation: 1102

just import a package in the buildpath servlet-api.jar file with a version greater than 3.0

Upvotes: -2

Sean
Sean

Reputation: 7737

By the screenshot it looks like you are importing servlet spec v2.5. The servlet annotations were added in servlet spec 3.0

http://docs.oracle.com/javaee/6/api/javax/servlet/annotation/package-summary.html

You will want to get the jar for a newer version then what you are currently using

Here is a chart showing the Tomcat version and the servlet spec it supports http://tomcat.apache.org/whichversion.html

Upvotes: 14

kandarp
kandarp

Reputation: 5047

annotation is not in javax.servlet package. It is under java.lang.annotation.*

Please refer below link.. http://docs.oracle.com/javase/tutorial/java/javaOO/annotations.html

Upvotes: 0

Related Questions