wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes the order of XML tags in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "the order of XML tags in web.xml" Watch "the order of XML tags in web.xml" New topic
Author

the order of XML tags in web.xml

Kalle Anka
Ranch Hand

Joined: Jul 06, 2005
Posts: 69
I have a feeling this is a stupid question...

In my book on the SCWCD i came across the following DTD(??)

<!ELEMENT web-app (icon?, ..., filter*, filter-mapping*,... servlet*, servlet-mapping*,...)>

My question is, must the filter tags always stand before the filtermapping... and those in turn be written before the servlet and servlet-mapping tags?

The reason of my question is that I get the following error messages from the servlet container (I think it is the container) when I place the filter tag after a servlet tag:

2005-jul-22 17:35:33 com.sun.enterprise.deployment.node.SaxParserHandler error
ALLVARLIG: "DPL8007: Invalid Deployment Descriptors in archive \E:\sun\samples\q
uickstart\hello3\ in deployment descriptor file WEB-INF/web.xml
Line 45 Column 11 -- The content of element type "web-app" must match "(icon?,di
splay-name?,description?,distributable?,context-param*,filter*,filter-mapping*,l
istener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-li
st?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,log
in-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)". "
CLI171 Command deploydir failed : Deploying application in domain failed; Error
loading deployment descriptors for hello3 Line 45 Column 11 -- The content of e
lement type "web-app" must match "(icon?,display-name?,description?,distributabl
e?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,se
ssion-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*)".
; requested operation cannot be completed
David Bridgewater
author
Ranch Hand

Joined: Apr 29, 2004
Posts: 44
No such thing as a stupid question!

If your SCWCD book is talking about DTDs, then it is a little bit out of date. The current exam is pitched at J2EE 1.4, which uses a different method (called schemas - .xsd files) to validate XML configuration files, including the web deployment descriptor, web.xml.

The interesting thing is that for the schema for web.xml, the order of the top-level elements directly underneath <web-app> no longer matters. That said, for backward compatibility, I tend to keep things in the order that they were in in the servlet 2.3 DTD - in which case filters are declared before servlets. (Also, you do get local problems with servlet containers - Tomcat, for example, even in its latest version, will still choke if a <servlet-mapping> for a servlet comes before the corresponding <servlet> element).

I would suggest that you make sure you get to grips with servlet 2.4 deployment descriptors - how to declare them appropriately to validate against a schema. And make sure you have an up-do-date container (e.g. Tomcat 5) which supports J2EE 1.4.

Hope that helps -

Best,

David.
[ July 22, 2005: Message edited by: David Bridgewater ]
Kalle Anka
Ranch Hand

Joined: Jul 06, 2005
Posts: 69
Thanx David for your fast reply! it really helped. And I also learned that it doesnt matters in the new schemas.

My book is brand new... It came out May 2005 I think (SCWCD exam study kit, Deshmukh et al). Its a really good one for someone just familiar with HTML and JavaScript. It actually both speaks of how to write web.xml with both DTD and schemas. But since the application server Im working on (the latest Orion) doesnt seem to support Servlet 2.4 nor JSP 2.0 (at least I doesnt get it to work) I choosed to continue working with the 2.3 DTDs.

thanx again!
David Bridgewater
author
Ranch Hand

Joined: Apr 29, 2004
Posts: 44
Hi Kalle...

You're welcome!

I would really recommend getting hold of Tomcat as well. It's free, very little trouble to set up, and supports J2EE 1.4 out of the box. Small download as well (you will need J2SE 1.4 as well, though, if you haven't got that already - but you probably do).

There are several topics in the current SCWCD where you need proper J2EE 1.4 support.

Best,

David.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: the order of XML tags in web.xml