Logan Jahnke Logan Jahnke - 7 months ago 16
Java Question

Not Found (Java Servlet)

<html>
<head>
<title>Currency Converter</title>
</head>

<body>

<h1>Currency Converter</h1>

<HR>

<form method=get action="http://localhost:8080/logan_jahnke_currency/app/Converter">

<P>Enter your amount of money is US Dollars below (do not include the dollar sign)

<P>For example: <tt>20</tt>

<P>Input amount in dollars: <INPUT NAME="dollars" TYPE=text size=50>

<select name="currency">
<option value="USD">United States Dollar</option>
<option value="ARS">Argentinean Peso</option>
<option value="AUD">Australian Dollar</option>
<option value="BRL">Brazilian Real</option>
<option value="GBP">British Pound</option>
<option value="CAD">Canadian Dollar</option>
<option value="CLP">Chilean Peso</option>
<option value="CNY">Chinese YuanRenminbi</option>
<option value="CZK">Czech Koruna</option>
<option value="DKK">Danish Krone</option>
</select>

<P><P><P><INPUT TYPE=submit> <INPUT TYPE=reset>

</form>
</body>
</html>


HTML File ^

XML File V

<web-app 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"
version="2.4">

<servlet>
<servlet-name>converter</servlet-name>
<servlet-class>logan_jahnke_currency.Converter</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>converter</servlet-name>
<url-pattern>/converter</url-pattern>
</servlet-mapping>

</web-app>


Directory:

app
converter.html
WEB-INF
classes
logan_jahnke_currency
Converter.class
lib
*.jar
web.xml


My initial HTML works fine at the address: http://localhost:8080/logan_jahnke_currency/app/converter.html

However, when I press submit, I get "Not Found".

Anyone see the problem? I cannot figure it out.

Answer

Based on your posted servlet mapping, this

action="http://localhost:8080/logan_jahnke_currency/app/Converter"

Assuming your application root context is logan_jahnke_currency then it should be

action="http://localhost:8080/logan_jahnke_currency/converter"

because you have

<url-pattern>/converter</url-pattern>

in your mapping.

Comments