You don't write programs in servlets. Servlets may be components in a web application though.
What you perhaps want is a good book. I suggest you give http://pdf.coreservlets.com a read, not only because it is free but also because it is very good. Whatever you do, you are not going to learn this by asking questions in a forum.