How to fix “javax.servlet cannot be resolved” error

How to set up class path in Eclipse IDE to include Server Runtime jars
(Aka I am getting errors that The import javax.servlet cannot be resolved. How do I fix it?)
If you get this compilation error, it means that you have not included the servlet jar in the classpath. The correct way to include this jar is to add the Server Runtime jar to your eclipse project. You should follow the steps below to address this issue:
Error Screen Shot:
Step 1- Right click on the project and open Configure Build Path menu (shown below):
Step 1 Screen Shot:
Step 2- Click on the libraries tab and choose Add library option:
Step 2 Screen Shot:
Step 3- From the Add Library screen, choose Server Runtime:
Step 3 Screen Shot:
Step 4- Choose Apache Tomcat v6.0 and hit finish:
Step 4 Screen Shot:
Now every thing is compiled correctly, as you would expect:
Step 5 Screen Shot:
This entry was posted in Computers and Internet. Bookmark the permalink.

6 Responses to How to fix “javax.servlet cannot be resolved” error

  1. hafiz muhammad danish says:

    thanks your method is working

  2. Pritish says:

    very greatful to you

  3. Prajakta says:

    Thank you

  4. Sunitha says:

    very helpful..thanks🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s