954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem running servlet in netbeans

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?

warlord902
Junior Poster
120 posts since Dec 2010
Reputation Points: 19
Solved Threads: 0
 

Did you associated your project with an instance of Tomcat?

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 
Did you associated your project with an instance of Tomcat?

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

warlord902
Junior Poster
120 posts since Dec 2010
Reputation Points: 19
Solved Threads: 0
 

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

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 
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.

warlord902
Junior Poster
120 posts since Dec 2010
Reputation Points: 19
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: