ERROR - import javax.servlet can't be resolved

Problem 

import javax.servlet can't be resolved.

Resolution

Either add servlet-api.jsr to the build path or specify the target runtime for the project.

Steps to add servlet-api.jar 

Right-click the project, click Properties.
Choose Java Build Path.
Click Add External JARs...
Browse to find servlet-api.jar and select it.
Click OK to update the build path.


Steps to specify the target runtime

Right-click the project, click Properties.
Click Target Runtime. 
Set the target runtime and click Ok.