Java servlets are Java’s technology for developing dynamic web applications.
Technically, servlets are java classes that conform to the Java Servlet API.
Servlet API allows java classes to respond to different types of requests; however, the most popular is HTTP requests.
Since servlet is a java class, you can write any valid java code within a servlet.
First servlet specification was released in 1997 and current servlet specification version 3.1 (as of this writing) was released as part of Java EE 7.
A servlet container usually implements a particular version of the servlet specification. You can read more about servlet containers and application containers @ Web Server, Web Container and Application Server.
For a servlet and JSPs to respond to requests, unlike normal java classes, servlets should be deployed to a servlet container like Apache Tomcat or an Application Sever like JBoss, which also contains the servlet container.
While developing a servlet you can add your servlet implementation class from your servlet container to classpath. In case of Apache Tomcat, it is the servlet-api.jar in the lib folder.
A server side technology such as servlet, JSP, PHP or ASP eventually sends html to the browser. There are excpetions to this rule as in case of technologies like applets, javafx, adobe flex etc. where language specific code is sent to the browser; however for these technologies to work, corresponding libraries need to be installed in the browser like java for applets and flash player for flex.