Search code examples
servletsmappingtomcat7web.xml

Can't start up servlet on the start


I think I have a problem with mapping on web.xml I always get 404 error. I am using tomcat 7. When I am trying the direct url to get to servlet that all work but when I start the project I can't see this page on the start.

This is my web.xml

<servlet>
  <servlet-name>login</servlet-name>
  <servlet-class>com.start</servlet-class>
  <load-on-startup>100</load-on-startup>
</servlet>


<servlet-mapping>
<servlet-name>login</servlet-name>
  <url-pattern>/login/*</url-pattern>
</servlet-mapping> 

and this is my servlet:

package com.start;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class login

*/
//
//@WebServlet("/login")
public class login extends HttpServlet {

Hope you can help. Thanks!


Solution

  • Use this tag in your web.xml to select the welcome page

    <welcome-file-list>
        <welcome-file>login</welcome-file>
    </welcome-file-list>