I took a picture of the sun today, and I was thinking about how the sun can damage your eye, I was wondering if the camera or lens could get damaged by this, or get burn in like some screens do?
Yes, it can. You should generally try to avoid direct pictures of the sun, especially for any extended period of time. It can (and will) damage the sensor. I shouldn't damage the lens however.
Additionally, you should avoid looking through the viewfinder at the sun as well.
In fact, check this question on somebody who had that problem!
There was a study done on this long ago in an astrophotography forum, taking watts, photons, metal properties, micro-lens properties, Bayer filter materials, etc. all into account. It was found that it took a surprisingly long amount of time before the image of the sun focused in one spot on a sensor could cause permanent damage. Don't quote me on this but I vaguely recall it was well over 30 seconds. Most of this was due to the very good heat-sinking properties of the sensor itself. Keep in mind though that wide-aperture wide-angle lenses will focus a smaller image of the sun and therefore risk damaging individual photosites faster than a smaller-aperture longer focal-length lens that creates a larger image of the sun spread over a larger area on the sensor.
Something that is of greater risk these days are those who are playing with pot-modded 5mw lasers, turning them into 50-120mw models with a simple turn of an onboard potentiometer. Many a camera sensor now has funny little squiggly lines burnt into it when they were playing with light-painting images on their walls and it accidentally reflecting off of something shiny back into the camera, or pointing the laser at the camera. That damage was instantaneous and irreparable.
As answered elsewhere, the sensors can get damaged (as can your eyes, which is far worse as you can replace a camera, you can't replace an eye!).
I'd not expect modern lenses to get damaged before that happens, but the extreme heat could in theory cause damage to plastic parts inside the lens (and camera) and possibly even to lens coatings.
In general, avoid pointing your camera directly at the full sun for more than a few seconds at a time it takes to quickly compose and take a picture.