wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Question on web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Question on web.xml" Watch "Question on web.xml" New topic
Author

Question on web.xml

Bhavna Jharbade
Ranch Hand

Joined: Sep 08, 2005
Posts: 69
hi all

please help me to find the correct answer to the following:

1) Does the order of elements in web.xml matter??

2)<taglib> element comes directly under <web-app> or it�s a sub element of <jsp-config>?

Thanks


SCJP1.4 (86%)
Steven Colley
Ranch Hand

Joined: Feb 18, 2005
Posts: 290
Hi Again,

1- yes, it does.(Take a look at the dtd file)

2- <taglib> under <jsp-config> - It's related to the old version of spec.
The new version of spec (for our exam) says that <taglib> is supposed to be under <web-app>.

Hope it help you!

cya!!


SCJP | SCWCD | SCBCD | SCWSD 5 | SCEA (I) 1.4 | SCEA 5 | IBM SOA 669
Bhavna Jharbade
Ranch Hand

Joined: Sep 08, 2005
Posts: 69
Hi Felipe

Can u please send me the link for new specifications.

Or else u can mail them to me, my id is bhavna.0112@gmail.com

Thank you
Gab Buda
Greenhorn

Joined: Mar 25, 2006
Posts: 24
Hi Bhavna, Felipe,

1) In servlet specs SRV.13.2 they say:
"The sub elements under web-app can be in an arbitrary order in this version of the specification."

2) The same pdf (servlet 2.4 spec) , lists on page 136 the child elements of <web-app> and there is no <taglib> (but there is a <jsp-config); instead, page 143: the <taglib> comes under the <jsp-config> element !

So if you have another references, Felipe, please argument...



Thank you
Gab

[ April 09, 2006: Message edited by: Gab Buda ]
[ April 09, 2006: Message edited by: Gab Buda ]

SCJP 1.4 (85%)<br />SCWCD 1.4 (94%)
Bhavna Jharbade
Ranch Hand

Joined: Sep 08, 2005
Posts: 69
Hi Felipe,Gab and others

I too found the things mentioned by Gab....but when I saw Felipe's response

I thought may be i have old specifications.

So Felipe please clear Gab and my doubt.

Thank you.
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

Gab is correct. The order of elements under the web.xml does not matter accroding to Servlet Spec 2.4. But the order of subelemnts under the main elements still important in this spec. That is, you can place <servlet> element anywhere in the web.xml. But <servlet-name> <servlet-class> should be in order.

The <taglib> element goes under <jsp-config>. But it is not required to declare taglibs using this tag as the container autosearch the .tld files in the directories specified in the spec.

Hope it help.

Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Rodrigo Alvarez
Ranch Hand

Joined: Apr 10, 2006
Posts: 75
Hi there,

(I'm new to this forum, this is my very first post,... soooo exited)

There are some cases when the order of web.xml elements influences the web app behaviors:

- listeners to servetContext,... are notified in the order in which they appear in the web.xml

- ServletFilters placed on a url-pattern process the (HttpServletRequest, HttpServletResponse) in the order in which the <filter-mapping> elements appears in the DD.

There are probably other examples.


It is a mistake to think you can solve any major problems just with potatoes.<br />--Douglas Adams
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

There are some cases when the order of web.xml elements influences the web app behaviors:


Yes, the placement of listener,filters ordering is important, in which sequence they executed. But this is if the same element type, and the ordering is done as per your application needs. If you place there in arbitary order it will not be error, but your application logic may not work as you desire.

Thanks
Steven Colley
Ranch Hand

Joined: Feb 18, 2005
Posts: 290
Hi folks,

Yes, you are dead right. The order doe snot matters. Tks.


Bhavna and Gab,

here: HFJ&S page 475.

"The OLD (before JSP 2.0)" ....

But actualy...now i got a bit confused too

Does it mean that we don't need to declared <taglib> anymore?
But is it mandatory don't declare that?
(sorry, have no time to test it now.)

Tks

Tks,
Steven Colley
Ranch Hand

Joined: Feb 18, 2005
Posts: 290
Hi, again...

i got this from the same page:

"The container will look first in your DD to see if you have made any <taglib> entries, and if you have, it will use those o help construct the map."

Tks.
Connie Ky Leung
Ranch Hand

Joined: Jan 29, 2006
Posts: 42
Originally posted by Felipe Pittella:
Hi, again...

i got this from the same page:

"The container will look first in your DD to see if you have made any <taglib> entries, and if you have, it will use those o help construct the map."

Tks.


<taglib> entry is not mandatory in web.xml but you can define one or more <tablib> entries if necessary.

The precedence of taglib map is specified in section of JSP 2.0 spec:

The following order of precedence applies (from highest to lowest) when building the taglib map (see the following sections for details):
1. Taglib Map in web.xml
2. Implicit Map Entries from TLDs
TLDs in JAR files in WEB-INF/lib
TLDs under WEB-INF
3. Implicit Map Entries from the Container

JSP.7.3.3 Taglib Map in web.xml
The web.xml file can include an explicit taglib map between URIs and TLD resource paths described using the taglib elements of the Web Application Deployment descriptor in WEB-INF/web.xml.

JSP.7.3.4 Implicit Map Entries from TLDs
The taglib map described in web.xml is extended with new entries extracted from TLD files in the Web Application.

JSP.7.3.5 Implicit Map Entries from the Container
The Container may also add additional entries to the taglib map. As in the previous case, the entries are only added for URIs that are not present in the map. Conceptually the entries correspond to TLD describing these tag libraries. These implicit map entries correspond to libraries that are known to the Container, who is responsible for providing their implementation, either through tag handlers, or via the mechanism described in Section JSP.7.3.9.

I only extract paragraphs that I think is important.
Hope this help.


SCJP 1.4 - 91%, SCWCD - 97%, SCJP 5.0 - 83%, SCJP 6.0, OCEJWCD - 80%
Ernesto Leyva
Ranch Hand

Joined: Feb 23, 2006
Posts: 62
May be it is container dependant
I remember I ran a test in Tomcat 5.5
I put taglib in DD just beneath
webapp and I do not remember getting
any error. But this is not guaranteed
since the spec says it should come under
jsp-config.
Steven Colley
Ranch Hand

Joined: Feb 18, 2005
Posts: 290
ok, i got it, the <taglib> is not mandatory, because the container also utilizes its map object for retrieving the related tag libraries under WEB-INF/* and jar/META-INF/*.

But my questions is..(i got a little confused regarding <jsp-config> ..

Is "<web-app><jsp-config><tag-lib> " OLD evrsion right?
and for the exam the correct place for <taglib> would be "<web-app><taglib>" right?


Tks.
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

Originally posted by Felipe Pittella:
ok, i got it, the <taglib> is not mandatory, because the container also utilizes its map object for retrieving the related tag libraries under WEB-INF/* and jar/META-INF/*.

But my questions is..(i got a little confused regarding <jsp-config> ..

Is "<web-app><jsp-config><tag-lib> " OLD evrsion right?
and for the exam the correct place for <taglib> would be "<web-app><taglib>" right?


Tks.


Leung gave the detail explaination. The tomcat does not validate the web.xml for synthatic correctness. Accroding to the Servlet 2.4 the <taglib> must be placed under <jsp-config>. But it is optional.

If you want to check. Place the <uri> item in .tld with SomeName1 and define <taglib-uri> with SomeName2 in web.xml, like

<web-app ..>
....

<taglib>
<taglib-uri> SomeName2 </taglib-uri>
<latglib-location> your tld location </taglib-location>
</taglib>


Try to use the tag library using

<%@taglib prefix="mylib" uri="SomeName2" %> in JSP
<mylib:sometag />

It should not locate the required tag library, as it defined under <web-app>

It should work

<%@taglib prefix="mylib" uri="SomeName1" %> in JSP
<mylib:sometag />

As the containe bulid implicit map of tag libraries.

Hope this help

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on web.xml