dcsimg
www.webdeveloper.com
Page 3 of 3 FirstFirst 123
Results 31 to 44 of 44

Thread: error counter help

  1. #31
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    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.

  2. #32
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    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?

  3. #33
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    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.

  4. #34
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    thanks!!!

    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.

  5. #35
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    Here's the little sample. The "trick" here is that a JSP can automagically put a bean into any context simply by referencing it there in the first place.
    Attached Files Attached Files

  6. #36
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    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?

    UPDATE
    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!!!!
    Last edited by jrthor2; 09-23-2004 at 12:46 PM.

  7. #37
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    I'd do that by changing the action to compare against the value of a request parameter like "maxCount" and then I'd put that as a hidden field in the form on the login JSP.

    <input type="hidden" name="maxCount value="5">

    There are stealthier alternatives but they would require a rework of the counter bean so IT knew what the max count was.

  8. #38
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    could you show me how to pass it to the counter bean, I believe this is the way we want it to work?

  9. #39
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    I'm not sure what you're asking. Do you want the counter bean to know about the max count or do you want the action responsible for that? The former is more secure.

  10. #40
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    Ok, here's a bit of a clean up with a more intelligent counter bean driving the lot.
    Attached Files Attached Files

  11. #41
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    This is great, thanks a million for all your help!!!!!!!!!!!!!!!!!
    Last edited by jrthor2; 09-24-2004 at 08:24 AM.

  12. #42
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    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?

  13. #43
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    Do it in the action that forwards to the other page. Get the counter reference from the session, reset(); setMaxCount(10); forward away.

  14. #44
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    Thanks, I had figured it out.

    Again, thanks for all your help, it is greatly appreciated!!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles