This happened to me a couple of months ago, but I never really got a proper solution as my friend who is a genius at the local Apple Store just swapped it over for me.
My iPhone 4 (4.2.1 with JB) is connected to my WiFi with a full signal (I'm sitting about 2 meters from the router), but doesn't respond to any internet apps. If I go into Safari it eventually comes back with a time out.... Mail does the same - as does Facebook.
If I open settings and check Airplane Mode on and off, everything works fine straight away. It works until I lock the phone and leave it for 5 mins. When I unlock and try to use an Internet app, it does the same again most times.
Its been working fine for the last few months - both non JB and JB. I don't want to have to go back to the Apple Store for a replacement - as its likely it'll be on 4.3.
I have 2 WiFi networks in my house and it does the same with them both. I also have several other WiFi devices (MacBook Pro, PC, iPod Touch etc) which all work fine... so it seems to be the iPhone.
Any ideas? I guess a System Restore is probably the easiest thing to try - but then having to re-load on 30gb of stuff is a pain in the backside!!
I would try downloading and installing Imsomnia from Cydia, it keeps you connected to your network even your iPhone is in sleep. If that doesn't work I would do a restore, that is most likely the only way.
Surely Insomnia will ruin my great battery life?!
I'll wait until Monday and see how I get on with the routers at work - then try restoring the phone if it's still the same.
Mine has been doing this for awhile now. LS router. Everything else in my house has no issues. Phone will say its connected but its not. Reset router....all is good. Not saying that's your issue.