0

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?

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by warlord902
0

Did you associated your project with an instance of Tomcat?

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

0

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

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.