How to resolve “The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path” problem in eclipse?

Problem :

Or if you “run as server” you can see the error like:
“The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path”

Solutions: 
Method 1:
Right Click on your project folder, Choose Property>Project Facets
Then select Runtimes and choose your desired server and click Apply>Ok

Method 2:

If you use Maven as build technology of your project then :
add  servlet-api-x.y.jar in your dependencies (in pom.xml file)

<!– https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api –>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>