How to fix import javax.servlet cannot be resolved
This error can be generalized to any library not resolving. Basically, you just need to add the missing jar. In the case of javax.servlet, the j2ee.jar needs to be added to your classpath.
In eclipse, go to the Project menu and select Properties. Then on the left select Java Build Path. Then on the right under the Libraries tab, select Add External JARs... and browse for j2ee.jar.
Once you've done this, the error should go away momentarily.
References
[Click to add or edit comments])
Please prepend comments below including a date