The Shaggy Dog Stories section of BadPuns.com contains longer jokes. The basic form is a story that builds up to a final punchline at the end. This punchline can be any form of wordplay (the most common being a pun or spoonerism on a well known phrase).
These jokes are also often known as "Groaners", for obvious reasons, or "Feghoots" (qf).
Some people with a penchant for semantic argument insist that they should always be called "Groaners", and that the term "Shaggy Dog Story" should only refer to a long story that doesn't lead anywhere.