Most people think it's "cute" when a puppy jumps up on their leg for attention and pets, even if the puppy is a St. Bernard. Then the dog grows up and -- watch out. Even small dogs/puppies should't jump up on people. There are people who are afraid of even small dogs. It is nice to have a well-trained dog sitting quietly for petting when visitors arrive.
There are lots of ways to teach this. This article focuses on a positive method of teaching (no knee-in-the-the-chest, no stepping-on-toes, no punishment).
Start with yourself. Pat your thighs and encourage the dog to jump up on you ("Cmon, puppy. Let's play"). When the dog/puppy jumps up, quickly push them off of you, still staying positive. ("Ooooh, isn't this a fun game? I gotcha, you silly puppy.") Laugh like you're having fun and continue to encourage the dog. Don't correct the dog or change your demeanor. ("I like this game, you goofy puppy.")
Keep playing this "game", and you will notice that the dog/puppy doesn't want to jump up if they're going to just get pushed back down. Most dogs will not want to get caught in this "trap". ("Hey, this isn't fun anymore.")
When the dog doesn't jump up on you, even with encouragement, reward the dog with it's favorite toy or some scratching under the chin (whatever the dog really enjoys).
Once you've convinced the dog that jumping on you (even with encouragement) isn't any fun, invite some friends over. Have them go through the same steps as above. Each time they visit, they should encourage the dog/puppy to jump up and play the "game".
Soon your dog will look at all visitors as a potential "gotcha". ("If I jump up on this person, they're going to push me down the way all the others did. I better just sit here with my tail wagging, and maybe they'll give me some pets or a treat.")