2011-09-16 11 views
0

私のアクションを登録した後、「最初のログイン試行時に強制的にパスワード変更」を作ることができるのである。どのように私は

public class LoginAction extends org.apache.struts.action.Action { 

    /** 
    * This is the action called from the Struts framework. 
    * @param mapping The ActionMapping used to select this instance. 
    * @param form The optional ActionForm bean for this request. 
    * @param request The HTTP Request we are processing. 
    * @param response The HTTP Response we are processing. 
    * @throws java.lang.Exception 
    * @return 
    */ 
    @Override 
    public ActionForward execute(ActionMapping mapping, ActionForm form, 
      HttpServletRequest request, HttpServletResponse response) 
      throws Exception { 
     LoginForm loginForm = (LoginForm) form; 
     HttpSession session = request.getSession(true); 

     String userName = loginForm.getUsername(); 
     System.out.print("name::" + userName); 

     List list=new ArrayList(); 
     String passWord = loginForm.getPassword(); 
     System.out.print("here is Actionform::" + loginForm.toString()); 
     list = StudentloginDAO.studentLogin(userName, passWord); 





     if (list.size() > 0) { 
       int id = (Integer) list.get(0); 

     System.out.println("id is" + id); 
     System.out.println(" List :: " + list.size()); 
     System.out.println(" List :: " + list); 
     List<StudentSessionObjectStore> list1 = StudentSessionObject.studentSessionObject(id); 
     System.out.println("new list" + list1.size()); 
     System.out.println("new list value" + list1); 
     session.setAttribute("getsessionObject", list1); 
     System.out.println("the Action attribute" + session.getAttribute("getsessionObject")); 
      return mapping.findForward(Constants.ACTION_FORWARD_SUCCESS); 
     } else { 
      request.setAttribute("LoginResult", Constants.ACTION_FORWARD_FAILURE); 
      return mapping.findForward(Constants.ACTION_FORWARD_FAILURE); 
     } 
    } 
} 

私の問題は、私はときに、ユーザ初めてログインフォースパスワード変更のためにchangePassword.jspに行きたいです。

誰でも私を助けることができますか?????

答えて

1

(FYI、掲載コードは、質問とは全く無関係です。)

なぜあなたはリストで、現在のユーザーを格納していますか?それは単一のユーザーです。

いずれにしても、ユーザーが初めてDBにログインするかどうかを追跡する必要があります。簡単な旗で、またはより長期的には、ログインした回数を追跡することで、より適切に対応できます。

「ログインしていますか?フラグが設定されていないか、ログイン数がゼロの場合は、「パスワード変更」ページにリダイレクトします。その時点で、実際にパスワードを変更し、サイトの移動を許可するまで、サイトの移動を禁止する必要があります。