permaculture playing cards*
The moose likes Servlets and the fly likes Editing the Deployment Descriptor (web.xml) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Editing the Deployment Descriptor (web.xml)" Watch "Editing the Deployment Descriptor (web.xml)" New topic
Author

Editing the Deployment Descriptor (web.xml)

Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

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.


Are you better than me? Then please show me my mistakes..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60765
    
  65

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!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Editing the Deployment Descriptor (web.xml)
 
Similar Threads
What's wrong with me?
Tomcat 404 error
servlets using JDBC
HelloWorld servlet not working
web.xml issue