JSP Tag Libraries

Скачать в pdf «JSP Tag Libraries»
12.1.3    Why custom tags and J2EE are a good fit


Now that you know what J2EE is, why is it so important to you, the JSP custom tag developer? Knowing how much J2EE offers—from a rich email API to a scaleable, enterprise-level component model—it isn’t difficult to imagine how your


Custom tags and J2EE


applications might benefit from it. Since JSP files may execute within J2EE-compliant application servers, with all those services available, you are likely to want or even need one or more of these standards in many of your web applications. For example, common tasks such as fetching a database connection or sending an email within your tags will require you to use J2EE standard interfaces. This chapter will demonstrate how to use many of these J2EE facilities from within your custom JSP tags.


The first J2EE member we’ll study, in anticipation of integrating it into our custom tags, is EJBs. In many applications, one common task for your custom tag will be to interact with EJBs. EJBs can be used to encapsulate business logic and database access at a very high level, letting the EJB container (the software in which the EJBs run) take care of low-level details such as generating proper SQL statements and handling transactions. These benefits render EJBs a popular choice for building software components; thus, it is no surprise that you will often need to let your dynamic web site (and namely, your custom tags) communicate with these server-side beans. Before we discuss how this interaction works, let’s take a moment to further specify what EJBs are.

Скачать в pdf «JSP Tag Libraries»