Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ordering of elements in DD

 
Vineela Devi
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Do we need to follow any specific order while declaring the elements in DD?

Regards,
Vineela
 
Vishnu Prakash
Ranch Hand
Posts: 1026
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

For the elements directlry under the <web-app> there is no specific order as per DD for servlet 2.4. But the sub-elements under the <web-app> elements, i think the order is still specific. As per the Servlet 2.3 the order is specific.

Thanks
 
Vineela Devi
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have tried this.But its throwing an error when the app is deployed

<servlet-mapping>
<url-pattern>*.abc</url-pattern>
<servlet-name>BeerSelect</servlet-name>
</servlet-mapping>

<servlet>
<servlet-class>com.example.web.BeerSelect</servlet-class>
<servlet-name>BeerSelect</servlet-name>
</servlet>

and reg the ordering of the subelements I dont think there is any specific order.

Please clarify.

Regards
Vineela
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Definitely you will get error. What you had done is

Read-Before-Declaration

Only when the container is able the read the servlet name specified in <Servlet-class> element it will load the servlet class. Before loading the class how can you access it.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Accoprding to Servlet 2.4, the subelement under web-app doesn't matter. But the order of subelement of subelement of <web-app> does matter.

I tried the following in tomcat 5.5.7

<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>*.abc</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>mypackage.MyServlet</servlet-class>
</servlet>

Giving me deplyment error.

I tried the same example on Sun Java App Server 8.1 UR2. There is no error, The application is running fine.

If I change the order of <url-pattern> and <servlet-name> , the application can not deply on both servers.

so Sun Java App Server 8.1 UR2 working accroding to the Servlet 2.4 specs.

Hope this help.

Thanks
 
Vineela Devi
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have changed interchanging the order of url-pattern and servlet-name and also sub-elements of some other elements.Those are working perfectly fine.

Iam using Tomcat 5.5


<servlet>
<servlet-name>BeerSelect</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>

<servlet-mapping>
<url-pattern>*.abc</url-pattern>
<servlet-name>BeerSelect</servlet-name>
</servlet-mapping>

is working fine in Tomcat.



Regards,
Vineela
[ November 19, 2005: Message edited by: Vineela Devi ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic