Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Configuration servlet problem

I try to configure hello servlet by following the url at http://wiki.eclipse.org/Jetty/Tutorial/Jetty_and_Maven_HelloWorld#Standard_Web_app_with_Jetty_and_Maven.

My code:
public class HelloServlet extends HttpServlet
{
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
        this.doPost(request, response);
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
        response.setContentType("text/html");
        ServletOutputStream out = response.getOutputStream();
        out.println("<html>");
        out.println("<h1>Hello World YYYY</h1>");
        out.println("</html>");
        out.flush();
    }
}

web.xml
<web-app
   xmlns="http://java.sun.com/xml/ns/javaee";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
   version="2.5">
        <servlet>
                <servlet-name>HelloServlet</servlet-name>
                <servlet-class>org.example.HelloServlet</servlet-class>
        </servlet>
        <servlet-mapping>
                <servlet-name>HelloServlet</servlet-name>
                <url-pattern>/hello-servlet/*</url-pattern>
        </servlet-mapping>
</web-app>

When startup jetty, there is no error. the output shows
...
     [java] 2010-03-22 22:12:22.573:INFO::Extract jar:file:/path/to/app/jetty-distribution-7.0.1.v20091125/webapps/hello-servlet.war!/ to /tmp/Jetty_0_0_0_0_8080_hello.servlet.war__hello.servlet__vf5mmf/webapp
     [java] 2010-03-22 22:12:22.651:INFO::NO JSP Support for /hello-servlet, did not find org.apache.jasper.servlet.JspServlet
     [java] 2010-03-22 22:12:22.716:INFO::Opened /path/to/app/jetty-distribution-7.0.1.v20091125/logs/2010_03_22.request.log
     [java] 2010-03-22 22:12:22.725:INFO::Started SelectChannelConnector@0.0.0.0:8080

However, when pointing to the http://localhost:8080/hello-servlet, it only 
lists content page

Directory: /hello-servlet/
META-INF/ 	4096 bytes 	Mar 22, 2010 10:10:40 PM
WEB-INF/ 	4096 bytes 	Mar 22, 2010 10:10:40 PM

I check the test-jetty-webapp, it appears that the setting and source java files are the same. 

What part do I configure incorrectly? Or how can I fix this issue?

Thanks for help.









Back to the top