JSP.5.8 Conventions and Other Issues


This section is not normative, although it reflects good design practices.

JSP.5.8.1 How to Define New Implicit Objects

We advocate the following style for the introduction of implicit objects:

  • Define a tag library.

  • Add an action called defineObjects ; this action will define the desired objects.

Then the JSP page can make these objects available as follows :

 <%@ tablig prefix="me" uri="......" %>  <me:defineObjects />  ....start using the objects.... 

This approach has the advantage of requiring no new machinery and of making the dependency very explicit.

In some cases there may be some implementation dependency in making these objects available; for example, they may be providing access to some functionality that exists only in some implementation. This can be done by having the tag extension class test at runtime for the existence of some implementation dependent feature and raise a runtime error (this, of course, makes the page not J2EE compliant, but that is a different discussion).

This mechanism, together with the access to metadata information, allows vendors to innovate within the standard.

Note

If a feature is added to a JSP specification, and a vendor also provides that feature through its vendor-specific mechanism, the standard mechanism as indicated in the JSP specification will "win." This means that vendor-specific mechanisms can slowly migrate into the specification as they prove their usefulness .


JSP.5.8.2 Access to Vendor-Specific information

If a vendor wants to associate with some tag library some information that is not described in the current version of the TLD, it can do so by inserting the information in a document it controls, inserting the document in the WEB-INF portion of the JAR file where the tag library resides, and using the standard Servlet 2.2 mechanisms to access that information.

The vendor can now use the ID machinery to refer to the element within the TLD.

JSP.5.8.3 Customizing a Tag Library

A tag library can be customized at assembly and deployment time. For example, a tag library that provides access to databases may be customized with login and password information.

There is no convenient place in web.xml in the Servlet 2.2 spec for customization information A standardized mechanism is probably going to be part of a forthcoming JSP specification, but in the meantime the suggestion is that a tag library author place this information in a well-known location at some resource in the WEB-INF/ portion of the web application and access it via the getResource() call on the ServletContext .



Java 2 Platform, Enterprise Edition. Platform and Component Specifications
Java 2 Platform, Enterprise Edition: Platform and Component Specifications
ISBN: 0201704560
EAN: 2147483647
Year: 2000
Pages: 399

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net