I typed in a simple servlet example from the book "Tomcat Kick Start" (Sams).  Basically I put the html and servlet class as follow:

$CATALINA/webapps/mybasic_servlet/CurrencyForm.html
$CATALINA/webapps/mybasic_servlet/WEB-INF/classes/CurrencyConverter.class

When I start Tomcat, and access: http://localhost:8080/mybasic_servlet/CurrencyForm.html and type a number in the text input and submit, the browser returns a 404 error

The requested resource (/mybasic_servlet/servlet/CurrencyConverter) is not available.

If I add a web.xml file to $CATALINA/webapps/mybasic_servlet/WEB-INF/, and the web.xml uses
   <servlet-mapping>
        <servlet-name>Currency Converter</servlet-name>
        <url-pattern>/convert</url-pattern>
    </servlet-mapping>

and changes my html to  <FORM METHOD=GET ACTION="">
Now after restarting Tomcat, and access: http://localhost:8080/mybasic_servlet/CurrencyForm.html and type a number in the text input an submit, this time the servlet gets triggered.


I have enclosed the files and would really apprceciate if someone explain this 404 error to me.

Thanks in advance.

-chris



<!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>

    <display-name>Currency Converter</display-name>
    <description>
        This is a simple web application with an HTML form passing
        a single parameter (amount of dollars) to a servlet for conversion.
    </description>

    <servlet>
        <servlet-name>Currency Converter</servlet-name>
        <servlet-class>CurrencyConverter</servlet-class>

		<init-param>
            <param-name>rate</param-name>
            <param-value>0.65</param-value>
        </init-param>
    </servlet>

	<servlet-mapping>
        <servlet-name>Currency Converter</servlet-name>
        <url-pattern>/convert</url-pattern>
    </servlet-mapping>

	<servlet-mapping>
        <servlet-name>Currency Converter</servlet-name>
        <url-pattern>*.con</url-pattern>
    </servlet-mapping>

 </web-app>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to