Trying to count number of attempts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • itgaurav198
    New Member
    • Oct 2007
    • 41

    Trying to count number of attempts

    Hi all,

    I have a JSP that asks for userid and password. I want to develop an application that should be able to check how many attempts the same user has taken so that he can be redirected to some another page when he gives wrong id/ pwd three times.

    If possible please provide some example code.

    thanks
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by itgaurav198
    Hi all,

    I have a JSP that asks for userid and password. I want to develop an application that should be able to check how many attempts the same user has taken so that he can be redirected to some another page when he gives wrong id/ pwd three times.

    If possible please provide some example code.

    thanks
    You just add a session variable and do count on your authorization page.
    And check the value every time user checks for authorization.

    Debasis Jana

    Comment

    • itgaurav198
      New Member
      • Oct 2007
      • 41

      #3
      Originally posted by dmjpro
      You just add a session variable and do count on your authorization page.
      And check the value every time user checks for authorization.

      Debasis Jana
      hi,
      thanks for ur response.
      This is the case if i am using JSP and what about if as a login page i make use of html page.

      thanks

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        Originally posted by itgaurav198
        hi,
        thanks for ur response.
        This is the case if i am using JSP and what about if as a login page i make use of html page.

        thanks
        Look at this following diagram.

        login_page(HTML )->authorization_ page(JSP) [Here you bind the session variable and do count the value]
        And you can call JSP page from a HTML page when you submit the HTML form.

        Debasis Jana.

        Comment

        • abhishekbrave
          New Member
          • Dec 2007
          • 79

          #5
          Originally posted by dmjpro
          Look at this following diagram.

          login_page(HTML )->authorization_ page(JSP) [Here you bind the session variable and do count the value]
          And you can call JSP page from a HTML page when you submit the HTML form.

          Debasis Jana.
          hi,
          can u give me any idea how to implement this. if i create a session variable in JSP page then how i will use a loop count on that for the same user.

          Comment

          • dmjpro
            Top Contributor
            • Jan 2007
            • 2476

            #6
            Originally posted by abhishekbrave
            hi,
            can u give me any idea how to implement this. if i create a session variable in JSP page then how i will use a loop count on that for the same user.
            Only one Session created for a one Browsing Session.
            If you don't know browsing Session then go for Google.
            So when you first time check the user authentication then you have to bind a session variable say "user_attem pts" then if fails then for second time in authorization page you will find that bound variable and increment the variable as the user fails and check every time how many times user attempts.

            Now have a closer look at my code.

            Code:
            if(session.getAttribute("user_attempts")!=null)
            //for second time and onwards
            {
            int user_attempts = (Integer)session.getAttribute("user_attempts").intValue();
            user_attempts++;
            if(user_attempts==max_attempts){
            //your code goes here
            }
            session.setAttribute("user_attempts",new Integer(user_attempts));
            }
            else
            //for the first time
            {
            session.setAttribute("user_attempts",new Integer(1));
            }
            I think the total scenario is clear to both of you.

            Debasis Jana

            Comment

            Working...