File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

404 error or resource not available error

 
budsy remo
Ranch Hand
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
budsy remo
Ranch Hand
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Vibhuti Goel
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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???
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic