GeeCON Prague 2014*
The moose likes Tomcat and the fly likes HTTP 404 Servlets do not run Tomcat 5.0. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Tomcat
Bookmark "HTTP 404 Servlets do not run Tomcat 5.0." Watch "HTTP 404 Servlets do not run Tomcat 5.0." New topic
Author

HTTP 404 Servlets do not run Tomcat 5.0.

mallika arora
Greenhorn

Joined: Aug 02, 2007
Posts: 5
I am trying some examples from Head First Servlet book. I have J2SDK 1.4.2_13 installed with Tomcat 5.0. HTML page opens fine when I do http://localhost:8080/Beerv1/form1.html but when this HTML page calls Servlet, it gives HTTP status 404 error.

Here is what's in web.xml:

<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 web-app_2_4.xsd" version="2.4">
<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>
</web-app>

Here is Servlet code:

package com.example.web;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class BeerSelect extends HttpServlet
{

public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("Beer Selection Advice<br>");
String c = request.getParameter("color");
out.println("<br>Got beer color" + c);
}
}


This is HTML page calling Servlet:

<html>
<body>
<h1 align="center">Beer Selection Page</h1>
<form method="POST" action="SelectBeer.do">Select beer characteristics<p>
Color:<select name="color" size="1"
<option>light
<option>amber
<option>brown
<option>dark
</select>
<br><br>
<center>
<input type="SUBMIT"
</center>
</form></body></html>


Please advice. Is there any Tomcat settings that need to be changed?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTTP 404 Servlets do not run Tomcat 5.0.