Since it sounds like you have a recurring problem, you can safely assume you have liagment and/or tendon damage. Yes, the doctor will tell you to stay off it and let it heal. Unfortunately there is no other way. The fact it keeps happening means you are not letting it heal properly.
As bad as this sounds, you need to stay off it until it can handle tennis without pain. The more you abuse it while it is healing, the worse it will be down the road, eventually becoming a chronic problem.