It's not a secret anymore!*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Deployment Descriptor Order Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Deployment Descriptor Order" Watch "Deployment Descriptor Order" New topic
Author

Deployment Descriptor Order

Allan Moster
Ranch Hand

Joined: Sep 14, 2001
Posts: 153
Do we really have to follow this order in the deployment descriptor (web security)?
<security-constraint>
<login-config>
<security-role>
If yes, why?
Pradeep Chopra
Ranch Hand

Joined: Nov 19, 2000
Posts: 219
Dear Allan,
Here is the DTD for <web-app> element:
<!ELEMENT web-app (icon?, display-name?, description?, distribut-able?,
context-param*, filter*, filter-mapping*, listener*, servlet*, servlet-mapping*,
session-config?, mime-mapping*, welcome-file-list?, error-page*,
taglib*, resource-env-ref*, resource-ref*, security-constraint*, login-config?,
security-role*, env-entry*, ejb-ref*, ejb-local-ref*)>
The order in which sub-elements are there in DTD should be followed while writing DD file.
Also note the meaning of following
* : 0 or more occurence
? : 0 or 1 occurence
+ : 1 or more occurence
| : means or
if no symbol than mandatory with exactly one occurence
I hope it helps.
Thanks and regards
Pradeep
Java Certification Test Simulators � J@Whiz, SCWCD@Whiz http://www.whizlabs.com/jwhiz

Whizlabs Software<br />Success, certified!<br /> <br />Web: <a href="http://www.whizlabs.com" target="_blank" rel="nofollow">http://www.whizlabs.com</a>
Tim Duncan
Ranch Hand

Joined: Aug 20, 2001
Posts: 150
The short answer is "yes", except that all three are optional :-)
Why? ... because that's the order that the DTD specifies.
Note that some app servers choose to be less strict about order, however Tomcat is not one of them.
Allan Moster
Ranch Hand

Joined: Sep 14, 2001
Posts: 153
Essentially, what you're saying is we cannot deviate from this format?
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Allan
The short answer to your first question is: yes.
The short answer to you second question is: because they said so.

On a more serious note:
I am by no means an XML guru, but my understanding is the whole point of it is to simplify and standardize a way to transmit information between two entities. The Deployment descriptor specifies the order in which the tags must come in order to simplify the communication. That way the a DTD I create will look the same and folow the same format as one that you create. It also allows the server to know exactly which tags are expected when and eases the parsing of the DTD by the server.
hope that helps a little bit, I'm sure someone else knows a bit more on it and will add to this for you....

------------------
Dave
Sun Certified Programmer for the Java� 2 Platform


Dave
Allan Moster
Ranch Hand

Joined: Sep 14, 2001
Posts: 153
Hi Tim,
I'm buying your answer that some app servers MAY not be strict on this order.
Thanks.
Tim Duncan
Ranch Hand

Joined: Aug 20, 2001
Posts: 150

Which is ok if you know where you're going to deploy, but bad practice if you want to remain portable.
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Yes, I work with WebLogic and it doesn�t complain about the order of the tags, at least some wich I�ve tryied, the most funny is that if you use the jsp compiler from WL it complains but you can run it and doesn�t have problems.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
It depends mostly on the type of parser they are using for reading web.xml file. if you use validating parser then it definately complains about ur non-conformance. if you use non-validating (as the name suggests) it never cares about the ordering or cordinality/optionality of the attributes
Sridhar
Originally posted by Marcos Maia:
Yes, I work with WebLogic and it doesn�t complain about the order of the tags, at least some wich I�ve tryied, the most funny is that if you use the jsp compiler from WL it complains but you can run it and doesn�t have problems.

Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
yes, SridharS I agree, this behavior I�ve said is with the defaul configuration for WL6.0 and 6.1.
regards.
PS - You should change your name to match JavaRanch rules(or a sheriff will tell you to do so), take a look at: http://www.javaranch.com/name.jsp
[This message has been edited by Marcos Maia (edited October 24, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Deployment Descriptor Order
 
Similar Threads
Authentication - Authorization
JAAS and EJB Server authorization
<web-resource-collection>
> 1 role-name in security-role
Problem with deployment-descriptor's error-page mapping