JavaServer Pages (JSPs) are based on the concept of server-side parsing. A JavaServer Page is an HTML page with Java statements embedded in it. The JSP specification defines certain special tags that can be embedded within the HTML page. In a normal working scenario, the JSP pages are parsed by a JSP compiler within the application server and converted into a Java servlet with the generated code embedded within the Java servlet as a set of Java statements. The generated Java servlet is then compiled as a normal servlet and loaded into the Java servlet container. The Java servlet is then used to process the user requests. In effect, the JSP specification simplifies the development of Java servlets, thus enabling specialized user interface (UI) application component providers to focus on building Web-enabled UIs for their applications. More importantly, JSP allows you to separate the development of the content and business logic of a Web application from the look and feel of the application. The JSP specification defines the following set of tags that can be used by application component providers:
JSP Tag LibraryThe JSP specification does allow developers to extend the JSP functionality and add custom tags in the JSP page. To develop custom tags, you need to write a custom JSP tag library to support the custom tags because the JSP engine that parses the JSP will have no idea how to interpret and process the custom tags. The primary advantage offered by building a JSP tag library is the encapsulation of complex processing code in a separate Java class. This encapsulation also enables the processing logic and, hence, the custom tags in the JSP tag library to be reusable across different JSPs in the application. The behavior of the custom tags (its processing logic) can be customized with the ability to pass attributes to the Java class performing the processing for the custom tags. This is an added benefit to the reusable feature of custom tags. Moreover, as a part of building a JSP tag library, the JSP specification defines a set of interfaces and classes that need to be implemented or used by an application component provider. This ensures that the JSP tag libraries that an application component provider builds are compliant with the J2EE specification. Visual composing tools are available from different vendors to create JSPs as well as to build custom tag libraries and embed them in the JSPs. Because these tools conform to the JSP specification, an application component provider can build JSPs and JSP tag libraries using any of the J2EE-compliant tools and can deploy the JSPs and JSP custom tag libraries in any J2EE-compliant containers or application servers without encountering any nonconformance problems. |