Hi,

I am learning struts 2 framework and i have also used OGNL in it for data transfer.

The problem is when i run the Login.jps page on apache tomcat server through Eclipse Indigo , i get the error "HTTP Status 404 - /Priyanjan_banking/Login.jsp"

Please help me out .

The code is given below
Login.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib uri="/struts-tags" prefix="s"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>HOME - PRIYANJAN Banking</title>
</head>
<body>
    <s:form action="login">
        <a:actionerror />
        <s:textfield name="log.user_id" label="User ID"></s:textfield>
        <s:password name="log.user_pass" label="Password"></s:password>
        <s:submit></s:submit>
    </s:form>


</body>
</html>

Login.java

package com;

public class Login {

    String user_id;
    String user_pass;

    public String getUser_id() {
        return user_id;
    }
    public void setUser_id(String user_id) {
        this.user_id = user_id;
    }
    public String getUser_pass() {
        return user_pass;
    }
    public void setUser_pass(String user_pass) {
        this.user_pass = user_pass;
    }



}

LoginAction.java

package com;



import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {

    /**
     * 
     */

    private static final long serialVersionUID = 1L;
    Login log;

    public Login getLog() {
        return log;
    }

    public void setLog(Login log) {
        this.log = log;
    }

    public String execute() throws Exception{

        if(log.user_id.equalsIgnoreCase("java")&&log.user_pass.equalsIgnoreCase("struts")){
            return SUCCESS;
        }
        else{
            addActionError("User id , password do not match");
            return "error";
        }
    }

}

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<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_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>Priyanjan_banking</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
    <welcome-file>Login.jsp</welcome-file>
  </welcome-file-list>




<filter>
<filter-name>Struts-intercept</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>

<filter-mapping>
<filter-name>Struts-intercept</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>


</web-app>

struts.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC 
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="mypack" extends="struts-default">
    <action name="login" class"com.LoginAction">
      <result name="success">/welcome_user.jsp</result>
      <result name="error">/index.jsp</result>
      <result name="input">index.jsp</result>
    </action>
<package>
</struts>

Please help me .
I just want to get started , run this basic , because when it runs i will start adding features to it.

Thanks in advance

Member Avatar for LastMitch

I just want to get started , run this basic , because when it runs i will start adding features to it.

@prnjn

On your login.jsp, What is

<s:form action="login">

Where does the info go to?

On your struts.xml This is line

<action name="login" class"com.LoginAction">

Is that where the info goes to? You need to set it correctly

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.