• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding order of elements in DD and in TLD

 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Could anybody let me know about the order of elements in Deployment Discriptor and in TLD file.Is the order of elements important in both?

lets take an example like:<init-param>
<param-value> javaranch</param-value>
<param-name> SCWCD</param-name>
</init-param>

Please expalin with some examples also


Thankx
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The order of top elements does not matter, but the order of subtags does. You can write listeners before servlets, or vice-versa. But you cannot change the order of their subtags.
 
Kunal Jag
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could anybody let me know about the order of elements in Deployment Discriptor

The tags in a web.xml are order dependent in Servlet 2.3 and earlier specifications. For example, the <servlet> tag must come before the <servlet-mapping>, this is the order they are declared in the DTD. 6.However, starting from Servlet 2.4 specification, the elements in the web.xml file need not appear in any specific order. Furthermore, Christophe is correct that you cannot change the order of their subtags.

Regards,
 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The order of top elements does not matter, but the order of subtags does. You can write listeners before servlets, or vice-versa. But you cannot change the order of their subtags.




I used below web.xml in Tomcat .It works fine even i have changed the order of subtags like <param-value> came before <param-name> etc. But when i write <servlet-mapping> before <servlet> then it did not work.


<?xml version="1.0" encoding="ISO-8859-1" ?>


<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<login-config></login-config>

<session-config>10</session-config>



<servlet>
<servlet-class>fourthservletwithconstructorwitharguments</servlet-class>



<init-param>
<param-value>shyam</param-value>
<param-name> ram </param-name>
</init-param>


<servlet-name>pradeep</servlet-name>

</servlet>




<servlet-mapping>

<url-pattern>*.qazz</url-pattern>

<servlet-name>pradeep</servlet-name>

</servlet-mapping>

[ June 16, 2008: Message edited by: pradeep singh ]
[ June 16, 2008: Message edited by: pradeep singh ]
 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any update?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Patience is a Virtue
 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any update?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic