tags:

views:

281

answers:

0

hi friends, I have created the application in which when session is timed out the control is forward to login page.But login page is comming with error message with required filed error.That is the form is submitted at the time of session timed out.

my code of action class is -

public ActionForward login(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionErrors errors =new ActionErrors();

        String target=null;
        int userId=0;
        String mobileNo = null;
        String password = null;
        javax.xml.ws.Holder<java.lang.Integer> userIdOut =null;

    try
    {


                    webService = new SBTSWebService();
                    HttpSession UserSession = request.getSession();
                     SBTSForm login = (SBTSForm) form;
                     mobileNo = login.getMobileNumber();
                     password = login.getPassword();

                     userIdOut = new Holder<Integer>();

                     webService.getSBTSWebPort().getSBTSAuthentication(mobileNo,password,userIdOut);
                     userId=userIdOut.value;
                     UserSession.setAttribute("userId",userId);
                     if(userId == -1)
                     {
                            userId=Integer.parseInt(UserSession.getAttribute("userId").toString());
                            errors.add("userId",new ActionMessage("error.check.unknown",userId));
                            target="failure";
                     }
                     else
                     {


                            target="login";

                    }



   }

          catch (NoClassDefFoundError ne)
          {
              target="error";

          }
          catch (Exception e)
          {
              target="error";

          }
          if(!errors.isEmpty())
          {
           saveErrors(request,errors);
          }


   return mapping.findForward(target);
 }

my Action form is

/* * To change this template, choose Tools | Templates * and open the template in the editor. */

package com.sbtsclient.form;

import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.ValidatorForm;

/** * @author Prashant Ghoderao * @Company Parallelminds * */ public class SBTSForm extends ValidatorForm{ private String mobileNumber; private String password; private String control; private String childName; private int userId;
private int childId;

public int getChildId() {
    return childId;
}

public void setChildId(int childId) {
    this.childId = childId;
}

public String getChildName() {
    return childName;
}

public void setChildName(String childName) {
    this.childName = childName;
}

public String getMobileNumber() {
    return mobileNumber;
}

public void setMobileNumber(String mobileNumber) {
    this.mobileNumber = mobileNumber;
}

public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}

/**
 * @return the control
 */
public String getControl() {
    return control;
}

/**
 * @param control the control to set
 */
public void setControl(String control) {
    this.control = control;
}

/**
 * @return the userId
 */
public int getUserId() {
    return userId;
}

/**
 * @param userId the userId to set
 */
public void setUserId(int userId) {
    this.userId = userId;
}
@Override

public void reset(ActionMapping mapping, HttpServletRequest request) { mobileNumber=null; password=null; control=null; childName=null; userId=0; childId=0; }

}

struts config :-

    <action path="/downloadMyPdfFile"
            type="com.sbtsclient.action.DownloadFileAction"
            parameter="fileName">
    </action>

</action-mappings>

I want remove the reqired field message from the login page at the time of session time out. please resolve my issue.