• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Editing the Deployment Descriptor (web.xml)

 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am having a huge problem. I am using tomcat, and whenever I am adding a new servlet (I am still learning, so I have to do lot of practice), I am editing the web.xml file according to the newly deployed servlet. For an example, If my web.xml file has entries for HelloWorld.java, and if I am adding a new servlet called Hi.java, I am replacing the entries of the HelloWorld.java to Hi.java. In this case if I want to check HelloWorld.java again, then I have to reedit the web.xml file. To make my question clear, please have a look at the following web.xml file.

This is my first web.xml file which has entries for the HelloWorld.java, and only that servlet is in the directory now.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd"> -->

<web-app>
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>


Here I am adding a new servlet called Hi.java to the folder. In this case, I am editing the previous web.xml file to the following.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd"> -->



but in this case I am loosing the entries for the first servlet and if I need to excute it then I have to reedit this file. What is the answer for this? Please help.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you removing the entries for the first servlet when adding the second?

Of course if you remove the entries, the first servlet will no longer be defined. It's like asking "I pulled out the plug for the refrigerator to plug in the oven, but now the refrigerator doesn't work!" Leave them both plugged in!
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Why are you removing the entries for the first servlet when adding the second?

Of course if you remove the entries, the first servlet will no longer be defined. It's like asking "I pulled out the plug for the refrigerator to plug in the oven, but now the refrigerator doesn't work!" Leave them both plugged in!


Hi, Thanks for the reply. I followed your advice and manages to solve the issue. I didn't do that before because I have had already messed up with JEE installation, it simply gave me "not compatible " notification. Then I installed tomcat, did a big deal to make everything up and work. After that the TomCat configuration in NetBeans gave me some hard time and search for info. After that, I didn't want to mess with anything else!! Now I followed your advice and everything is OK!! Thanks a lot for your quick reply. I really appreciate it...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic