Results 1 to 8 of 8
  1. #1
    nida is offline Member
    Join Date
    Mar 2009
    Posts
    14
    Rep Power
    0

    Default No action instance for path /login could be created

    Hello!
    I am a new user of Struts , when i click the submit button , following error message is received :
    No action instance for path /login could be created
    Following is the code of struts-config.xml file
    <struts-config>
    <form-beans type="org.apache.struts.action.ActionFormBean">
    <form-bean name="LoginForm" type="net.form.LoginForm" />
    </form-beans>

    <global-exceptions>
    </global-exceptions>
    <global-forwards></global-forwards>

    <action-mappings>
    <action path="/login" name="LoginForm" validate="false" input="/index.jsp"
    type="net.LoginAction">
    <forward name="success" path="/Welcome.jsp" />
    <forward name="failure" path="/index.jsp" />
    </action>
    </action-mappings>

    <message-resources parameter="resource.MessageResource"></message-resources>

    </struts-config>

    and following is the code of index.jsp file
    <html:form action="login">
    <html:text property="userName"></html:text>
    <html:errors property="userName" />
    <br/>
    <html:password property="password"></html:password>
    <html:errors property="password"/>
    <html:submit/>
    <html:reset/>
    </html:form>
    </body>
    </html>

    can anyone plz hel me out...
    Thanks in advance
    Nida

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    805
    Rep Power
    6

    Default

    Have you checked the action class is residing in the folder what u specified? Check the folder struture once

  3. #3
    nida is offline Member
    Join Date
    Mar 2009
    Posts
    14
    Rep Power
    0

    Default

    The path of action class (instruts-config.xml ), was not correct ,..i have corrected that but now it is not redirecting to desired page Welcome.jsp...
    Thaaaaanx alot for ur support

  4. #4
    nida is offline Member
    Join Date
    Mar 2009
    Posts
    14
    Rep Power
    0

    Default

    i am facing another problem ...records are not inserted in data base , while i recvd the message of insertion..
    Following is the code of Action class

    package net.action;

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;

    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import net.form.LoginForm;

    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;

    import DB.DB;

    public class LoginAction extends Action {

    public ActionForward execute(ActionMapping mapping,ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    //DB d= new DB();
    String target = null;
    String name;
    String pass;
    LoginForm loginForm = (LoginForm)form;//new LoginForm();
    Connection con = null;
    String url = "jdbc:mysql://localhost:3306/";
    String db = "teralight";
    String driver = "com.mysql.jdbc.Driver";

    if(loginForm.getUserName()!=null && loginForm.getPassword()!=null)
    {

    target = "success";
    request.setAttribute("message", loginForm.getPassword());


    name=loginForm.getUserName();
    pass=loginForm.getPassword();
    StringBuffer sbQuery = new StringBuffer("");
    System.out.println("name is"+name);
    System.out.println("Connectig database !!!");

    try{
    Class.forName(driver);
    con = DriverManager.getConnection(url+db,"root","root");
    try{

    Statement st = con.createStatement();
    System.out.println("111111 !!!");
    // int val = st.executeUpdate("INSERT into usrs VALUES("+"name,"+"pass'"+")");

    sbQuery.append("INSERT INTO usrs(Name,Password) VALUES('");
    sbQuery.append(name + "','");
    sbQuery.append(pass + "')");

    System.out.println("1 row affected");

    }
    catch (SQLException s){
    System.out.println("SQL statement is not executed!");
    }

    con.close();

    }
    catch (Exception e){
    e.printStackTrace();

    }

    }
    else {
    target = "failure";
    }

    return mapping.findForward(target);
    }
    }

  5. #5
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    805
    Rep Power
    6

    Default

    One small suggestion.If u want to send some dynamically use preparedstatement instead of statement class.It will not create problem.

    Just change the statement part and include this
    PreparedStatement ps = con.prepareStatement("INSERT INTO USRS VALUES(?,?)");
    ps.setString(1,name);
    ps.setString(2,pass);
    int updateCount = ps.executeUpdate();
    System.out.println("Update Count "+ updateCount);

    Try the above chunk of code and tellme if there are any problems

  6. #6
    nida is offline Member
    Join Date
    Mar 2009
    Posts
    14
    Rep Power
    0

    Default

    I got a type mismatch error in line
    con.prepareStatement("INSERT INTO USRS VALUES(?,?)");
    how to resolve it ,..if i type cast it then database is not connected..
    Help me out

  7. #7
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    805
    Rep Power
    6

    Default

    IN usrs table are u having only 2 String fields? Just check whether u are having only 2 fields in usrs table.
    This typemismatch error comes if u are trying to set the value which is not having expected datatype or expected column.
    Try this
    con.prepareStatement("INSERT INTO USRS(name,password)VALUES(?,?)");
    ps.setString(1,name);
    ps.setString(2,pass);
    int updateCount = ps.executeUpdate();

  8. #8
    nida is offline Member
    Join Date
    Mar 2009
    Posts
    14
    Rep Power
    0

    Default

    My problem has been resolved and now data is inserted in table properly thanx RamyaSivakanth

Similar Threads

  1. Vector getting re-created with each call
    By nidhirastogi in forum Advanced Java
    Replies: 6
    Last Post: 10-17-2008, 07:37 AM
  2. Replies: 0
    Last Post: 06-25-2008, 12:41 PM
  3. Replies: 4
    Last Post: 11-05-2007, 05:14 PM
  4. Help, created a username and password box
    By cachi in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 04:21 AM
  5. create a tree when a new class is created
    By osval in forum Advanced Java
    Replies: 1
    Last Post: 08-06-2007, 08:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •