I'm new to struts and I want to create a new servlet which will print jsp pages into PDF format. My question is, do i have to put the servlet code in /lib directory or can I just place it in the source directory?
As long as you declare the servlet in your web.xml file, the class files can be anywhere in your class path. That means they could either be in a jar file in the WEB-INF/lib directory, or they could be in WEB-INF/classes along with all your other classes.
Something you might want to consider would be to put this functionality in a Struts Action rather than a servlet. An Action can do pretty much anything a servlet can do, and using Actions rather than Servlets in a Struts application is a more consistent architectural choice.