|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Hello all
I am new to XML, so sorry for this silly post. I am trying to use the <listener> to call my Servlet, which has implemented ServletContextListener and saved in ROOT/WEB-INF/classes, when the Tomcat server starts. However, Tomcat gave me these errors when it's starting: -------------------------------------------------------------------------------- org.xml.sax.SaxParseException: Element type "listener" must be declared. [ERROR] Digester -- Parse Error at line 10 column 12: Element type "listener" must be declared [ERROR] Digester -- Parse Error at line 11 column 12: Element type "listener" must be declared [ERROR] Digester -- Parse Error at line 45 column 11: The content of Element type "web-app" must match "<icon?, display name?, description?, distributable?, content param*. servlet*, servlet-mapping, session-config*, mime-mapping*, welcome-file-list*, error-page*, taglib*, resource-ref*, security-constraint*, login-config*, security-role*, env-entry*, ejb-ref*>".> -------------------------------------------------------------------------------- This is my web.xml: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> <web-app> <!-- Listeners --> <listener> <listener-class> InterestCounter </listener-class> </listener> <security-constraint> <web-resource-collection> <web-resource-name>Security</web-resource-name> <url-pattern>/client/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>administrator</role-name> <role-name>client</role-name> </auth-constraint> </security-constraint> <security-constraint> <web-resource-collection> <web-resource-name>Security</web-resource-name> <url-pattern>/administrator/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>administrator</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>FORM</auth-method> <form-login-config> <form-login-page>/login.html</form-login-page> <form-error-page>/login_error.html</form-error-page> </form-login-config> </login-config> </web-app> -------------------------------------------------------------------------------- Please anyone tell me what thing goes wrong with my code. Many many thanks!! Viola |
|
#2
|
|||
|
|||
|
Try throwing this on the top of your file. Replace the part you have that's similar to it.
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> The problem is you're trying to use an out of date version of the DTD. Be sure you're using Tomcat 4.0 or better, though. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > <listener> problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|