This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes 404 error or resource not available error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "404 error or resource not available error" Watch "404 error or resource not available error" New topic
Author

404 error or resource not available error

budsy remo
Ranch Hand

Joined: Sep 20, 2008
Posts: 103
1. i hav made a deployemnt environment which is "C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\Beer-v1"
2. inside the Beer-v1 i hav put form.html
here's the code for form.html
<html>
<body>
<h1 align="center">Beer Selection</h1>
<form method="post" action="/Beer-v1/SelectBeer.do">
Select Beer Characteristics
<p>
Color :
<select name="color" size="l">
<option value="light">light</option>
<option value="green">green</option>
<option value="brown">brown</option>
<option value="amber">amber</option>
<option value="dark">dark</option>
</select>
<br>
<center>
<input type="Submit" value="submit">
</center>
</form>
</body>
</html>
3. Directory of web.XML "C:\Program Files\Apache Software Foundation\Tomcat5.5\webapps\Beer-v1\WEB-INF"
4. The servlet the post method will call(it compiles whout ne error)
package com.example.web;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class beer extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("Beer Selection Advice<br>");
String c=req.getParameter("color");
out.println("<br>Got Beer Color"+c);
}
}
5. the web .xml file
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 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">
<servlet>
<servlet-name>beer</servlet-name>
<servlet-class>com.example.web.beer</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>
</web-app>
6. beer.class file's directory "C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\Beer-v1\WEB-INF\classes\com\example\web"
7. now wen i run the server and type "http://localhost:8080/Beer-v1/form.html" on the browser i see the form but when i click the submit button i get http error 404 or should i say SelectBeer.do not found .help me please
tong yuxin
Greenhorn

Joined: Jul 21, 2008
Posts: 19
hi,
try this , make the action as same as your url/mapping.
we are reading the same book. woo! really good book.
<html>
<body>
<h1 align="center">Beer Selection</h1>
<form method="post" action="SelectBeer.do">
Select Beer Characteristics


SJCP 98%
budsy remo
Ranch Hand

Joined: Sep 20, 2008
Posts: 103
tried that didn't work .
dude could you send me
the details of your environment variables. i think they are the source of problems.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41083
    
  43
Environment variables have nothing to do with this.

The very files you posted work just fine for me. Have you restarted the web app after deploying them?


Ping & DNS - my free Android networking tools app
Vibhuti Goel
Greenhorn

Joined: Sep 24, 2008
Posts: 3
i am having the same problem. and I've tried restarting the web-app many times. but its still not working
budsy remo
Ranch Hand

Joined: Sep 20, 2008
Posts: 103
Thanks for your time man!
And yes i have redeployed Again and again . I shutdown the server ,close the browser and then restart the whole thing.
I have jdk and apache installed am i missing anything else???
Which sw's do you have installed???
 
 
subject: 404 error or resource not available error
 
Similar Threads
http 404 error
Tomcat 5.5 - application development
Getting problem with post method
Cannot bring up a html page using tomcat 6.0
Problems with the Example from HF Servlets & JSP in Chapter 3