provided by: 
Originally published at Internet.comJSP Tag libraries provide a convenient framework for developing Web applications. They allow you to wrap custom functionality inside XML-like tags. By removing the "details" from the JSP page, it becomes easier to read. At the end of the day, however, JSP pages along with JavaBeans and tag libraries, get translated into servlets. So at runtime, it is the servlet that does the work.

Piroz Mohseni
With tag libraries, you can declare a custom tag and then associate some code with it and control when the code is invoked in relation to the opening or closing tags. The key class to make this work is TagSupport, which is part of the javax.servlet.jsp.tagext package. Note that this is not standard Java API. Most likely it will ship with your JSP/servlet engine, like Apache Tomcat.
A JSP page (regardless of whether it contains tag libraries or not) is processed from top to bottom. In a manner similar to the SAX API, various events are associated with this reading process. These "events" correspond to when the reader encounters a tag that is part of the tag library defined for the page. When the tag is first encountered, the doStartTag() method of TagSupport is called. By inheriting from TagSupport and overriding the doStartTag(), you can associate custom code and functionality to that event. As the reading process continues, it will eventually encounter the closing tag for the element and at that time it invokes the doEngTag() method...
Read article at Internet.com site