title: HTTP STATUS 404: The requested resource is not available
body: <p>I have this error when i started login.jsp form and type a username and password
  The error was
  HTTP STATUS 404: The requested resource is not available.</p>
  
  <p>What am i missing? any help?</p>
  
  <p>LoginAction.java</p>
  
  <pre><code>package com.tutorialspoint.struts2;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  import com.opensymphony.xwork2.ActionSupport;
  
  public class LoginAction extends ActionSupport {
  
   private String user;
   private String password;
   private String name;
  
  public String execute() {
    String ret = ERROR;
    Connection conn = null;
  
    try {
       String URL = "jdbc:mysql://localhost/struts_tutorial";
       Class.forName("com.mysql.jdbc.Driver");
       conn = DriverManager.getConnection(URL, "root", "");
       String sql = "SELECT name FROM login WHERE";
       sql+=" user = ? AND password = ?";
       PreparedStatement ps = conn.prepareStatement(sql);
       ps.setString(1, user);
       ps.setString(2, password);
       ResultSet rs = ps.executeQuery();
  
       while (rs.next()) {
          name = rs.getString(1);
          ret = SUCCESS;
       }
    } catch (Exception e) {
       ret = ERROR;
    } finally {
       if (conn != null) {
          try {
             conn.close();
          } catch (Exception e) {
          }
       }
    }
    return ret;
   }
  
  public String getUser() {
    return user;
   }
  
  public void setUser(String user) {
    this.user = user;
   }
  
  public String getPassword() {
    return password;
   }
  
  public void setPassword(String password) {
    this.password = password;
   }
  
  public String getName() {
    return name;
   }
  
  public void setName(String name) {
    this.name = name;
   }
  }
  </code></pre>
  
  <p>Login.jsp</p>
  
  <pre><code>&lt;html&gt;
   &lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
    &lt;title&gt;Login Example&lt;/title&gt;
   &lt;/head&gt;
      &lt;body&gt;
      &lt;html:form action="/login" focus="userName"&gt;
        Username : &lt;html:text property="userName" /&gt;
      &lt;br&gt;
        Password : &lt;html:password property="password" /&gt;
      &lt;br&gt;
       &lt;html:submit value="login" /&gt;
      &lt;/html:form&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Web.xml</p>
  
  <pre><code>&lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://java.sun.com/xml/ns/javaee" 
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  id="WebApp_ID" version="3.0"&gt;
  
  &lt;display-name&gt;Struts 2&lt;/display-name&gt;
  &lt;welcome-file-list&gt;
    &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  &lt;filter&gt;
    &lt;filter-name&gt;struts2&lt;/filter-name&gt;
    &lt;filter-class&gt;
       org.apache.struts2.dispatcher.FilterDispatcher
    &lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
    &lt;filter-name&gt;struts2&lt;/filter-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Struts Configuration </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE struts PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
  "http://struts.apache.org/dtds/struts-2.0.dtd"&gt;
  
  &lt;struts&gt;
   &lt;constant name="struts.devMode" value="true" /&gt;
    &lt;package name="helloworld" extends="struts-default"&gt;
  
      &lt;action name="loginaction" 
        class="com.tutorialspoint.struts2.LoginAction"
        method="execute"&gt;
       &lt;result name="success"&gt;/success.jsp&lt;/result&gt;
       &lt;result name="error"&gt;/error.jsp&lt;/result&gt;
      &lt;/action&gt;
  
    &lt;/package&gt;
  
   &lt;/struts&gt;
  </code></pre>
  
  <p>This is what i tried
  <a href="http://www.tutorialspoint.com/struts_2/struts_database_access.htm" rel="nofollow">http://www.tutorialspoint.com/struts_2/struts_database_access.htm</a></p>