can't seem to get my java servlet to work

can't seem to get my java servlet to work

The default testing page for Tomcat7 works just fine, but I can't seem to get my java servlet to work. I get the following errors:


HTTP Status 404 - /hello/hello
type Status report
message /hello/hello
description The requested resource (/hello/hello) is not available.
Apache Tomcat/7.0.26


I attempt to access my servlet with this address: http://localhost:8080/hello/hello

web.xml is as follows:

view plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped
 <web-app version="2.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xsi:schemalocation="http:/java.sun.com/dtd/web-app_2_3.dtd">  
<servlet>  
    <servlet-name>hello</servlet-name>  
    <servlet-class>test.HelloServlet</servlet-class>  
  </servlet>  
 
  <servlet-mapping>  
    <servlet-name>hello</servlet-name>  
    <url-pattern>/hello</url-pattern>  
  </servlet-mapping>  
</web-app> 
 <web-app version="2.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xsi:schemalocation="http:/java.sun.com/dtd/web-app_2_3.dtd">
<servlet>
    <servlet-name>hello</servlet-name>
    <servlet-class>test.HelloServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>hello</servlet-name>
    <url-pattern>/hello</url-pattern>
  </servlet-mapping>
</web-app>

my java file compiles with this command:
javac -cp '/usr/share/tomcat7/lib/servlet-api.jar' ./test/HelloServlet.java


and my java file is as follows:

view plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped
package test;  
 
import java.io.*;  
import javax.servlet.http.*;  
import javax.servlet.*;  
 
public class HelloServlet extends HttpServlet {  
  public void doGet (HttpServletRequest req,  
                     HttpServletResponse res)  
&nbs

[1] [2] [3] Next

Copyright © 2007-2012 www.chuibin.com Chuibin Copyright