• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Editing the Deployment Descriptor (web.xml)

 
Ranch Hand
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic