i'm creating a web App of handle all sorts of things like booking, registering users etc.
currently i'm struck on vey first step that is users login!!
all the presantation part is done using jsp and struts tiles, whenever i rub the application welcome page is shown, after that there is a need to login inorder to book tickets. now this login form is in two part i.e. a page in which other one is inserted as segement and bean created with input from the segment here is the code for both these files:
login.jsp(segement)
and the calling jsp code named as "signin.jsp"<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %> <%@taglib prefix="html" uri="http://struts.apache.org/tags-html" %> <html:errors header="error.header" footer="error.footer"/> <html:form action="/login.do" method="POST" focus="username"> <table> <tr><td>Username:</td><td><html:text property="username"/></td></tr> <tr><td>Password:</td><td><html:password property="password"/></td> <tr><td><html:submit value="Login"/></td></tr> </table> </html:form>
<%@taglib prefix="tiles" uri="http://struts.apache.org/tags-tiles" %> <tiles:insert page="/WEB-INF/layout/layout.jsp"> <tiles:put name="subtitle" value="Login"/> <tiles:put name="body" value="/WEB-INF/global/login.jsp"/> </tiles:insert>
and the loginbean(as named) code is
when i try to access the signin.jsp it is shown well( as expected) and if textbox are left blank and request is made it returns error as expected but if i left even a single field blank then it returns a error/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package beans; import javax.servlet.http.HttpServletRequest; import model.Login; import model.loginDAO; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; public class loginbean extends org.apache.struts.action.ActionForm { private String username,password; public loginbean() { super(); // TODO Auto-generated constructor stub } @Override public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); System.out.println(" performing validation"); if ((getUsername() == null || getUsername().length() < 1)&&(getPassword()==null || getPassword().length()<1) ){ errors.add("name", new ActionMessage("error.username.required")); // TODO: add 'error.name.required' key to your resources } //login object creation Login user= new Login(); user.setUsername(getUsername()); user.setPassword(getPassword()); //loginDAO object to access the database loginDAO search = new loginDAO(); user = search.getuser(user);//search method returns login object, methods searches for the list of registered users. System.out.println("user from database"+ user.getUsername());//never seen in server log file. if(!(getUsername().equals(user.getUsername())) || !(getPassword().equals(user.getPassword()))) errors.add("invalid", new ActionMessage("error.false.required")); return errors; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } }
i think you also want to see config.xml in order to go through here it is (code shown is a part of it)HTTP Status 500 - No action instance for path /login could be created
--------------------------------------------------------------------------------
type Status report
message No action instance for path /login could be created
description The server encountered an internal error (No action instance for path /login could be created) that prevented it from fulfilling this request.
--------------------------------------------------------------------------------
Apache Tomcat/7.0.14
it is showing error but when the values are entered it return that error??<action-mappings> <action input="/views/signin.jsp" validate="true" name="loginbean" path="/login" scope="request" type="controller.login"> <forward name="error" path="/views/signin.jsp"/> <forward name="member" path=""/> <forward name="employee" path=""/> <forward name="admin" path=""/> </action>
do ask if you think information provided is incomplete!
i'm totally confused what to do ?
thanks in advance.