title: calling Servlet from jsp <href> link is not working
body: <p>i am working on a spring mvc project and i have used Tomcat FORM authentication for login.
  and the application is working fine so now i am working on the logout implementation.
  the application is having home page (home.jsp) with logout link and i am trying to call a LogoutServlet as below.</p>
  
  <h2>LogoutServlet.java</h2>
  
  <pre><code>@WebServlet(urlPatterns={"/logout"})
  public class LogoutServlet extends HttpServlet  {
  
  protected void doGet(HttpServletRequest  request,HttpServletResponse response) 
        throws ServletException, IOException {
  
        // To logout the current user
        request.getSession().invalidate();
  
      // The user is now logged out so redirect the user to the welcome.jsp page .
      response.sendRedirect(request.getContextPath() + "/welcome.jsp");
    }
  </code></pre>
  
  <p>}</p>
  
  <h2>home.jsp</h2>
  
  <pre><code>&lt;body&gt;      
  
      &lt;a href="LogoutServlet"&gt;Logout&lt;/a&gt;
  
          &lt;form:form id="formDataBean" method="post" modelAttribute="formDataBean" action="submit" class="form" &gt;
  
          //form body
          .
          .
  
          &lt;/form:form&gt;
  &lt;/body&gt; 
  </code></pre>
  
  <h2>web.xml</h2>
  
  <pre><code>&lt;welcome-file-list&gt;
      &lt;welcome-file&gt;welcome.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
  
    &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/spring/root-context.xml,classpath*:gameResult-context.xml&lt;/param-value&gt;
    &lt;/context-param&gt;
  
    &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
    &lt;/listener&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/spring/appServlet/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;security-constraint&gt;
  
      &lt;web-resource-collection&gt;
        &lt;web-resource-name&gt;Admin&lt;/web-resource-name&gt;
        &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
        &lt;http-method&gt;GET&lt;/http-method&gt;
        &lt;http-method&gt;POST&lt;/http-method&gt;
      &lt;/web-resource-collection&gt;
  
      &lt;auth-constraint&gt;
        &lt;role-name&gt;tomcat&lt;/role-name&gt;
      &lt;/auth-constraint&gt;
  
      &lt;user-data-constraint&gt;
        &lt;transport-guarantee&gt;NONE&lt;/transport-guarantee&gt;
      &lt;/user-data-constraint&gt;
  
    &lt;/security-constraint&gt;
  
    &lt;login-config&gt;
      &lt;auth-method&gt;FORM&lt;/auth-method&gt;
      &lt;form-login-config&gt;
        &lt;form-login-page&gt;/login&lt;/form-login-page&gt;
        &lt;form-error-page&gt;/login-failed&lt;/form-error-page&gt;
      &lt;/form-login-config&gt;
    &lt;/login-config&gt;
  
  
  
   // i have a doubt on the below code as i don't know if it has to be there at all
   // because when ever i start the application (server) this servlet gets initialize 
   // and doGet() gets execute.
  
   &lt;servlet&gt;
      &lt;servlet-name&gt;LogoutServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.sample.servlets.LogoutServlet&lt;/servlet-class&gt;
    &lt;/servlet&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;LogoutServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/logout/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;  
  </code></pre>
  
  <p><strong>here is the problem :</strong>
  i want to call the LogoutServlet from logout link and redirect to welcome.jsp page but right now its not working, its throwing HTTP Status 404 error <code>(http://localhost:8080/gameResult/LogoutServlet).</code></p>