Also, what is wrong with the else part? If I make this "Else" instead of "else", I get a syntax error:
Ok this is the THIRD time I've answered this one. Maybe if I type slower and in bold.
The string "Else" does not mean anything to Java. The correct string for the else token is "else". Java is case sensitive. Tokens that begin with capital letters are meant to be class names; not instance names, not control structure tokens.
Else is wrong
else is right
I still maintain that this counter should be a session attribute.
Ok, I got your point the first time. I said that it worked when I changed it to "else". I spoke with some other people here and this is how we would like it to work, instead of making a class to import. When you come to the login page, it sets a session variable "counter". If you login with the wrong info, the login action class checks this counter, if it less than 3, it increments the counter and takes them back to the login page. If it is greater than 3, it takes them to a customer service page. If the user credentials are correct, the login action class forwards them to a success page and the session counter is reset to 0. Could you or someone help me accomplish this?
I've started a little example for you with the intention of replying to your other thread with it. Maybe tonight. It has the counter bean, a servlet for the login action and three JSPs: login, success, failure. I used straight MVC to keep the additional Struts baggage out since this is so trivial.
I actually got something working, setting a counter in the session, my login action class reads the session variable and if we caught any erros, increments the variable. If the variabble is greateer than 3, it forwards you to a customer service page.
When I take your CounterBean.java code and replace my error counter code, I get this error in websphere:
The public type CounterBean must be defined in its own file.
What does this mean?
I got your code to work with mine, thanks a ton!!!! One other thing. How would I get your CounterBean to accept a maxlimit limit, so that if a different page wants 5 retries instead of 3, I could pass in a maxlimit size of 5, or if the maxlimit size was empty, it uses a default of 3?
Thanks again for all your help, I really appreciate it!!!!
I came across another issue. When I login succesffuly and go to another page that has a form on it that I want to use this counter bean for, how do I reset the counter to 0 only the first time they load the page, so I can have a counter with 10 retries, but starts at 0 and counts up?