You are using == to test string equality instead of equals()
-R

Sent from my iPhone

On Aug 8, 2008, at 11:52 PM, "Narasimha Raju Naidu" <[EMAIL PROTECTED]> wrote:

hi to all,


       im sending my code please check where i am doing mistake

form.jsp
---------------
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<html:errors/>
<div style="background-color:#fcc;border: 1px dashed
blue;width:280px;margin:2px;">
<html:form action="/login.do">
<table cellpadding=2 align=center style="font-family:verdana;font- size:15;">

<tr><td><b>User Name</b></td>
<td><html:text property="userName"/></td></tr>
<tr>
<td><b>Password</b></td>
<td><html:password property="pwd"/></td></tr>
<tr><td>
<html:submit property="submit" value="Connect"/></td><td>
<html:reset property="reset" value="Re-Try"/></td></tr>
</table>
</html:form>
</div>

--- ----------------------------------------------------------------------
formbean
---------------------------
import javax.servlet.http.*;
import org.apache.struts.action.*;

public class LoginBean extends ActionForm
{
   private String userName;
   private String pwd;

   public void setUserName(String userName)
   {
     this.userName=userName;
   }
   public String getUserName()
   {
     return userName;
   }
   public void setPwd(String pwd)
   {
     this.pwd=pwd;
   }
   public String getPwd()
   {
     return pwd;
   }

   public void reset(ActionMapping mapping,HttpServletRequest request)
   {
     System.out.println("--reset LoginForm--");
     this.userName="";
     this.pwd="";
   }

public ActionErrors validate(ActionMapping mapping,HttpServletRequest
request)
   {
     ActionErrors aes=new ActionErrors();
     if(userName==null||userName=="")
     {
       aes.add("userName",new ActionError("UserName is Required"));
     }
     if(pwd==null||pwd=="")
     {
       aes.add("pwd",new ActionError("Password is Required"));
     }
     return aes;
   }
}

--------------------------------------------------------------
action class
----------------------

import javax.servlet.http.*;
import org.apache.struts.action.*;


public class LoginAction extends Action
{
   public ActionForward execute(ActionMapping mapping,ActionForm
form,HttpServletRequest request,HttpServletResponse response) throws
Exception
   {
     LoginBean login= (LoginBean)form;
     return mapping.findForward("succ");
   }
}

-------------------------------------------------------------------
struts-config.xml code
------------------------------
<form-beans>
   <form-bean name="LBBean" type="LoginBean"/>
</form-beans>


<action path="/login" type="LoginAction" name="LBBean" scope="request"
input="/pages/login.jsp" validate="true">
   <forward name="succ" path="/pages/succ.jsp"/>
 </action>


while compiling im not getting any errors while running if i did not give any input i am getting bullet not the exact error what i gave. waiting for
you people's valuable replys.

Regards,

Narasimha Raju




uni...

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to