title: Maven project: Http 404 error
body: <p>Got the following files for a Maven+Spring+Hibernate+MySQL project (under NetBeans):</p>
  
  <pre><code>project /
     + Web Pages /
        + WEB-INF /
           + views /
              + login.jsp
           + servlet-context.xml
        + index.jsp
        + web.xml
     + Source /
        + users /
           + User.java
           + UserDAO.java
           + UserController.java
  </code></pre>
  
  <p>This is web.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" 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"&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/servlet-context.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>This is servlet-context.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:beans="http://www.springframework.org/schema/beans"
         xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
         xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"&gt;
  
      &lt;!-- Enable @Controller annotation support --&gt;
      &lt;mvc:annotation-driven /&gt;
  
      &lt;!-- Map simple view name such as "test" into /WEB-INF/test.jsp --&gt;
      &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix" value="/WEB-INF/views/" /&gt;
          &lt;property name="suffix" value=".jsp" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- Scan classpath for annotations (eg: @Service, @Repository etc) --&gt;
      &lt;context:component-scan base-package="users"/&gt;
  
      &lt;!-- JDBC Data Source. It is assumed you have MySQL running on localhost port 3306 with 
      username root and blank password. Change below if it's not the case --&gt;
      &lt;bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"/&gt;
          &lt;property name="url" value="jdbc:mysql://localhost:3306/private"/&gt;
          &lt;property name="username" value="private"/&gt;
          &lt;property name="password" value="private"/&gt;
          &lt;property name="validationQuery" value="SELECT 1"/&gt;
      &lt;/bean&gt;
  
      &lt;!-- Hibernate Session Factory --&gt;
      &lt;bean id="mySessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="myDataSource"/&gt;
          &lt;property name="packagesToScan"&gt;
              &lt;array&gt;
                  &lt;value&gt;users&lt;/value&gt;
              &lt;/array&gt;
          &lt;/property&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;value&gt;
                  hibernate.dialect=org.hibernate.dialect.MySQLDialect
              &lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;!-- Hibernate Transaction Manager --&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="mySessionFactory"/&gt;
      &lt;/bean&gt;
  
      &lt;!-- Activates annotation based transaction management --&gt;
      &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>And got index.jsp:</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;body&gt;
          &lt;% response.sendRedirect("login"); %&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But when I launch the proyect, over Glassfish server, then it replies:
  <strong>HTTP Status 404: Not Found
  The requested resource is not available</strong></p>
  
  <p>URL is "<strong>localhost:8080/private/login</strong>"</p>
  
  <p>UPDATE:
  This is the controller:</p>
  
  <pre><code>package user;
  imports[...]
  @Controller
  public class UserController {
  
      @Autowired
      private UserDAO userDAO;
  
      @RequestMapping(value="/login", method=RequestMethod.POST)
      public ModelAndView doLogin(HttpServletRequest request){
          ModelAndView model = new ModelAndView();
          String email = request.getParameter("usermail");
          String password = request.getParameter("userpass");
  
          List&lt;User&gt; users = userDAO.findUser(email, password);
          if (!users.isEmpty()){
              model.addObject("user", users.get(0));
              model.setViewName("home"); //will be endpoint in case of success
          }else{
              model.addObject("message", "Invalid user email or password!");
              model.setViewName("error"); //will be endpoint for any error
          }
  
          return model;
      }
  
  }
  </code></pre>
  
  <p>And this is the login.jsp file:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
           pageEncoding="UTF-8"%&gt;
  &lt;%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
      &lt;head&gt;
          &lt;meta charset="UTF-8"/&gt;
          &lt;title&gt;web&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form:form method="POST" action="login"&gt;
              &lt;ul&gt;
                  &lt;li&gt;
                      &lt;label&gt;email:&lt;/label&gt;
                      &lt;form:input type="email" id="usermail" path="usermail"/&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;label&gt;password:&lt;/label&gt;
                      &lt;form:input type="password" id="userpass" path="userpass"/&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;input type="submit" value="Login"/&gt;
                  &lt;/li&gt;
              &lt;/ul&gt;
          &lt;/form:form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>