Reputation: 60
I'm getting this error when trying to create a servlet of the same name as one I deleted. The original one was going nowhere so i deleted it to start again, it's not in the project tree and not in the physical folder, so I can't understand why this is not working. I did refresh the project and also shut down and restarted Eclipse.
Any help appreciated. Is this some quirk of Eclipse or is there something I have to do? Here is my web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>first</display-name>
<welcome-file-list>
<welcome-file>home.html</welcome-file>
<welcome-file>contactus.html</welcome-file>
<welcome-file>adminlog.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>login</servlet-name>
<servlet-class>login</servlet-class>
</servlet>
<servlet>
<servlet-name>adlogin</servlet-name>
<servlet-class>adlogin</servlet-class>
</servlet>
</web-app>
Upvotes: 2
Views: 5211
Reputation: 9935
If you take new Servlet Class in an IDE (eg : Eclipse), the IDE will create a Servlet
class and configure it (ServletClass
and ServletMapping
) in the web.xml
automatically.
But, even if you delete your class, the configuration might still remain in web.xml
. Remove that configuration and create the servlet again. It should work!
Upvotes: 2
Reputation: 1688
When you delete your class, the servlet mapping stubbornly remains in the 'web.xml' file. THerefore, the IDE misbehaves. Either change the mapping or name your servlet something different than the previous one.
Upvotes: 1
Reputation: 7630
Servlet Mapping Exist In web.xml. Remove it's mapping.if you remove servlet but it's mapping in web.xml
, it will not allow to create same name servlet again.
Upvotes: 0