Here is what should work.
Since you are using struts, I am presuming you have something like this
create a variable in the action class say int attemptsCtr = 0;
now when user tries to login, in the action class look for a request variable
if its not null and has value then convert that value to integer and assign it to
now process that if this value is <3 then increment it by 1 and then reset the request object
else if its equal to 3 then whatever you want to do
I don't like using sessions much so here is the next part...
create a hidden field in the jsp
<input type="hidden" name="attemptsCtr" value="<bean:write name="attemptsCtr"/>"/>
thats about it...