# web.xml elements

Sandya Bhaskara

Ranch Hand

Posts: 73

posted 12 years ago

is the order of elements in xml imortant?

i mean is this valid??

<context-param>

<param-value>....</param-value>

<param-name>...</param-name>

</context-param>

one more ques...

if u want to give more than one context param.how would u declare it?

<context-param>

<param-name>...</param-name>

<param-value>....</param-value>

</context-param>

<context-param>

<param-name>...</param-name>

<param-value>....</param-value>

</context-param>

or

<context-param>

<param-name>...</param-name>

<param-value>....</param-value>

<param-name>...</param-name>

<param-value>....</param-value>

</context-param>

what about listeners?

i mean is this valid??

<context-param>

<param-value>....</param-value>

<param-name>...</param-name>

</context-param>

one more ques...

if u want to give more than one context param.how would u declare it?

<context-param>

<param-name>...</param-name>

<param-value>....</param-value>

</context-param>

<context-param>

<param-name>...</param-name>

<param-value>....</param-value>

</context-param>

or

<context-param>

<param-name>...</param-name>

<param-value>....</param-value>

<param-name>...</param-name>

<param-value>....</param-value>

</context-param>

what about listeners?

Sandy<br />SCJP1.4 SCWCD1.4<br />SCBCD(preparing)

Welsh Ding

Greenhorn

Posts: 14

posted 12 years ago

1.I don't know whether the order is sensitive, sorry.

2.if there more than one context init parameter, you should write like this:

<context-param>

<param-name>...</param-name>

<param-value>....</param-value>

</context-param>

<context-param>

<param-name>...</param-name>

<param-value>....</param-value>

</context-param>

one by one.

2.if there more than one context init parameter, you should write like this:

<context-param>

<param-name>...</param-name>

<param-value>....</param-value>

</context-param>

<context-param>

<param-name>...</param-name>

<param-value>....</param-value>

</context-param>

one by one.

Welsh<br />SCJP 1.4

Shane Semanek

Greenhorn

Posts: 4

posted 12 years ago

I am preparing for the SCWCD exam and had the same question. According to section SVR.13.2 of the Java Servlet Specification version 2.4, "the sub elements under web-app can be in any arbitrary order in this version of the specification". As far as the order of the context-param element, the XML Schema declares the context-param element to be of type param-valueType which lists the elements in the order <param-name> followed by <param-value>. So, if the Deployment Descriptor where validated against the XML Schema, the following would be valid:

<context-param>

<param-name>test</param-name>

<param-value>TestParam</param-value>

</context-param>

and the following would be invalid:

<context-param>

<param-value>TestParam</param-value>

<param-name>test</param-name>

</context-param>

<context-param>

<param-name>test</param-name>

<param-value>TestParam</param-value>

</context-param>

and the following would be invalid:

<context-param>

<param-value>TestParam</param-value>

<param-name>test</param-name>

</context-param>

Don't get me started about those stupid light bulbs. |