I have got everything right and my project is compiling. But I am experiencing problem with servlets, when I right click on a servlet and click on run in netbeans then I get following two error:
1) Class "Servlet1" neither has a main method not it a servlet specified in web.xml
2) Class "Servlet1" does not have a main method.

My serlvet is defined in web.xml, i have checked it in web.xml:

<servlet>
        <servlet-name>Servlet1</servlet-name>
        <servlet-class>Servlet1</servlet-class>
    </servlet>
<servlet-mapping>
        <servlet-name>Servlet1</servlet-name>
        <url-pattern>/Servlet1</url-pattern>
    </servlet-mapping>

And our teacher was running servlet without any main method, so I can't figure out what is wrong with it?

Did you associated your project with an instance of Tomcat?

Did you associated your project with an instance of Tomcat?

It started working after I restarted netbeans, must be some problem with it only.

Be careful sometimes IDE fail to shut down Tomcat. Then you will get error as "can't start, port in use" or similar

Be careful sometimes IDE fail to shut down Tomcat. Then you will get error as "can't start, port in use" or similar

ok, thanks
I'll take care of it.