*
The moose likes Servlets and the fly likes adding listener to DTD file but not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "adding listener to DTD file but not working" Watch "adding listener to DTD file but not working" New topic
Author

adding listener to DTD file but not working

jayash samaiya
Greenhorn

Joined: Apr 07, 2013
Posts: 2
When I am using the following code in DTD file all works fine.
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<servlet>
<description>
</description>
<display-name>ServletNsep</display-name>
<servlet-name>ServletNsep</servlet-name>
<servlet-class>
com.tcs.h107.AccountController.ServletNsep</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletNsep</servlet-name>
<url-pattern>/ServletNsep</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>


But when I add the listener declaration as <listener>
<listener-class>
MyServletContextAttributeListener
</listener-class>
</listener>
into this file and run the applicatin again it tells HTTP Status 404 - /Nsep_Account/transactions_home.jsp

Description-webpage not available.


Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Your listener class has to be in a package, just like your servlet classes do. (It doesn't have to be the same package, just a package.)
jayash samaiya
Greenhorn

Joined: Apr 07, 2013
Posts: 2
Paul Clapham wrote:Your listener class has to be in a package, just like your servlet classes do. (It doesn't have to be the same package, just a package.)


Still the problem persist :-) . Am I making any mistake in declaring the listener in DTD file.
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

I don't understand what your listener has to do with the 404, how are they linked?


SCJP, SCWCD.
|Asking Good Questions|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: adding listener to DTD file but not working