A servlet is a piece of program that sits on your webserver, handles incoming requests and often returns a dynamically built HTML( or browser-renderable ) content. A JSP( Java Server Pages ) on the otherhand, is an advanced HTML content that can contain inline-java code and calls to Servlets. A Servlet is a content generator while JSP is the content itself which can include within, calls to different content generators. Hope that helps, Ajith
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
It is important to remember, though, that a JSP file is really just an alternative way of specifying a servlet. A JSP is always converted to a servlet and compiled before it can be run to generate a page. JSP is easier to use if your page has a lot of static content (HTML which is the same for every request) and only a small number of relatively simple calls to generate dynamic content. Traditional servlets are a better choice if you need more sophisticated processing or only have a small amount of static HTML in the page. Don't forget that there are also other ways of mixing static and synamic content on the same page. Several of my projects use WebMacro or another templating engine of my own design, or generate XML which is formatted using XSL stylesheets.
A servlet is a Java class that can be invoked from a browser (thru the good services of a servlet-enabled web server). This class receives an object representing the calling web element and an object representing the answer to be sent to the browser, typically this answer is an HTML page (painfully) created thru a series of println calls. A servlet is thus not well suited to create complex pages. A JSP page on the other hand is an HTML page with Java code embeded, which is handy if you have lots of static HTML (tables, gifs, etc.) The embedded Java code is expected to instantiate some Java objects and put dynamic values inside <TD>, <INPUT> and other HTML tags. As Frank remarked a JSP page is actually converted in a servlet before it's run so its efficiency is generally acceptable. Hope this helps (and my apologies for any misleading info)