• Post Reply Bookmark Topic Watch Topic
  • New Topic

web.xml as dd

 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to me,reasons of why xml file is used as dd are:
1.Through XML we can make our own tags and put the required information in an organized way.
2.XML is widely accepted as standard language for declaring internet related issues.
Please tell me if there is any other reason of why we use xml file as dd.
 
Tim Holloway
Bartender
Posts: 18414
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually you can't put your own tags into a web.xml deployment descriptor. There's an XML schema for web.xml (older versions used a DTD), and if your deployment descriptor has invalid or misplaced tags, the appserver will fail to validate the web.xml and will refuse to start the app.

Reasons why XML was picked include:

1. XML can be validated (see above)

2. XML can be manipulated with any text editor - no need for a custom configuration utility program. Conversely, many text editors have XML-aware modes to help keep you from creating bad XML.

3. XML is self-descriptive. The tags are more or less meaningful descriptions of what they define.

4. XML is 2-dimensional. Unlike the old Windows INI or Java properties files, you can not only define single-value items, you can also define collections of items.

5. XML is a well-defined standard, so everyone knows what its rules are and there are existing debugged tools that can work with it. For example, Tomcat uses the Apache Digester to parse the web.xml file instead of having to have its own unique parsing code.

How's that for a start?
 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,
Thanks a lot for your nice reply.
Kindly clarify these things :

4. XML is 2-dimensional. Unlike the old Windows INI or Java properties files, you can not only define single-value items, you can also define collections of items.

Please explain this.

doubt: I understood that xml was already a standard when web.xml was choosen as a dd,but if xml would not have been a standard at that time,i think text file could also have been used as a dd and parsers etc. could have been created for that text file which could have validated that file.
And why not properties file was choosen,anyway,parser is there for xml and parser can also be for properties file.

So,the main reason according to me:XML was already a standard language and its behavior of having well organized data attracted people to make xml as the file for dd.

One more thing,if XML is so good ,why can't only XML be used for all declarations(i mean,can we remove properties file,so that for any declaration, we will use xml file only).
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain this.

I take the leasure to reply

In Windows INI files, or in Java properties files, you have only key=value. For example :
color=red
name=john

With XML, you can nest tags, so you can define several values for one entity. For example, look at the welcome-file-list :

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

This is another advantage of using XML over property files.


think text file could also have been used as a dd and parsers etc. could have been created for that text file which could have validated that file.

Yes, nothing is impossible. For example, log4j's property files. At first, log4j's configuration was done via a property file. Now we can use XML also. It's clean.

why can't only XML be used for all declarations

Which declarations are you talking about ?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before web.xml was adopted, controlling the configuration of servlets was a nightmare. I worked with an early edition of JRun - it had properties files scattered all over the place with bizarre naming conventions. You should be glad that order has been imposed and java web applications have a high degree of portability.

Bill
 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to all of you.I got the answer.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!