You need to change your wireless router.
I had the same issue with my new iPhone 4S. But I sloved it by swtiching to a different wireless router. With my older router which was Netgear, my iPhone 4S could connect my wifi, but can't go online. At the same time my iPhone 3G wifi works fine. I did some research and found some routers don't support iOS devices very well. Then I changed my wireless router to D-Links. Now my iPhone4 S wifi works perfectly.
Another way to test wheather your iPhone 4S wifi works or not is to go to some public wifi, such as Apple store, or Starbucks. If you can connect your phone with their wifi, it means your phone is fine and there must be something wrong with your wirless router. Try to use different brand name wireless router, try to use WAP instead of WEP for your secuirty setting.
Hope my experience will help you to slove the wifi problem.
Jayson