• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About listner entry in the DD???

 
Amitkumar Dhama
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all this is Amit, I got this question from one of the mock exam...
Consider the following DD entry....

<web-app.....>
<servlet>
............
</servlet>
<listner>
<listner-class>com.mylistners.loglistner</listner-class>
</listner>
</web-app>

based on the above entry what will be the result....

The Correct answer is "parse exception".....

can anybody explain me why is it giving parse exception?
In the headfirst's Attribute and listner chapter DD is given like this one only..


Does the location of llistner entry in the DD matters and, if so where it should be???

Thanking in advance.......
 
Balasubramani Dharmalingam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It wont throw parse exception. It is the correct way to declare the listeners.
where u got this question..?
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<listner>
<listner-class>com.mylistners.loglistner</listner-class>
</listner>

that should be listener
 
Amitkumar Dhama
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is given in javaranch mock exam i forgot the question ID....

the question was same..

Does the location of the listner entry in the DD matters...

and when will it throw an parse exception??? Please let me know...

Thanking in advance...
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amit,

The JavaRanch exam is based on old spec J2EE 1.3. So the DD for this spec require specific order of sub-elements. That is the listener definations should come before servlet definations. That is why the parse error. For J2EE 1.4 there is order restrictions for sub-elements of <web-app>

Thanks
 
Kuppusamy Venkatasubramanian
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Narendra,

"For J2EE 1.4 there is order restrictions for sub-elements of <web-app>"
Did you mean
"For J2EE 1.4 there is NO order restrictions for sub-elements of <web-app>"?

SAM
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Sorry, That is typo. For J2EE 1.4 there is NO order restrictions for sub-elements of <web-app>. But there is order restrictions for sub-element under subelements of <web-app>

Thanks
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Thats what Narendra intended.
 
Vineela Devi
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Narendra,

I have tried interchanging thr order of sub-elements of sub-elements of web-app.It didnt give me any problem.

I have tried this:

<servlet>
<servlet-class>com.example.xxx</servlet-class>
<servlet-name>testOrder</servlet-name>
</servlet>

and its working fine.

Iam using Tomcat5.5

Please clarify.

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

I have tried interchanging thr order of sub-elements of sub-elements of web-app.It didnt give me any problem.


I think we have discussed little bit on this in your previous post.

I also created a sample application by interchanging the order of sub-elements of sub-elements of web-app. The .war I deployed in tomcat 5.5.7. It is working fine. But When I tried to deploy on Java Application Server8.1 UR2 it doesn't allow me to deploy the .war due to this interchanging.

The specification clearly says that such interchaging is not allowed (error). and the Reference implementation of Java Application Server8.1 UR2 behaves the same. So the exam point of view, we should consider that the order of sub-elements of sub-element of <web-app> is important.

I am using NetBean IDE to test the web.xml. It also give the XML validation error, if I try to validate the web.xml file.

Correct me, if my assumption is not right.

Thanks
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The specification clearly says that such interchaging is not allowed (error)


I like to know the page number of the spec.

From Spec


The sub elements under web-app can be in an arbitrary order in this version(2.4 of the specification.


Nothing has been mentioned about the order of sub-elements of sub elements under web-app element.

This can be conformed under a high-end application server like weblogic (or) websphere.
[ November 22, 2005: Message edited by: Vishnu Prakash ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic