Challenge mapping servlets to URLs using WEB.xml
843841Jul 8 2005 — edited Sep 1 2005Hi Everyone,
I am new to servlets and having a few challenges mapping servlets to URLs. I am using Tomcat 5 and have written my own WEB.xml file to go
along with my application. The important pieces of information regarding my challenge are as follows:
1). The web application is in the following directory structure:
Instal_/Tomcat 5/webapps/ferngully
Note: The application has the recommended Tomcat 5 structure, with Instal_/Tomcat 5/webapps/ferngully/WEB-INF/classes, etc...
2). The application is using a servlet with the name "PreferencesServlet.class" contained in a package called "userpreferences".
3). From html pages I am using the following URL to reference the above mentioned servlet "http://localhost/ferngully/Preferences".
4). The WEB.xml file is structured exactly as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>Preferences</servlet-name>
<servlet-class>userpreferences.PreferencesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Preferences</servlet-name>
<url-pattern>/Preferences</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
As best I can determine from the information I have provided the servlet "userpreferences.PreferencesServlet"
should respond to url requests of the kind "http://localhost/ferngully/Prefernces"......however instead of my servlet receiving a request I am receiving the
following error message from Tomcat:
HTTP Status: 404
The requested resource (/ferngully/Preferences) is not available.
If anybody could provide me with information to remedy the lack of functionality that I am facing it will be greatly appreciated.
Kind Regards
Davo