805 OCPJP 6 Questions 788 SCJP 5 questions 650 OCPJWCD 5 questions 600 OCAJP 7 questions 610 OCPJP 7 questions 510 Upgrade to OCPJP 7 questions 900 Java J2EE Qns

Tutorials

SCWCD : JSP tag libraries

Configure the deployment descriptor to declare one or more tag libraries, deactivate the evaluation language, and deactivate the scripting language.

A tag library is a collection of actions that encapsulate some functionality to be used from within a JSP page. A tag library is made available to a JSP page through a taglib directive that identifies the tag library via a URI (Universal Resource Identifier).

The URI identifying a tag library may be any valid URI as long as it can be used to uniquely identify the semantics of the tag library.

The URI identifying the tag library is associated with a Tag Library Description (TLD) file and with tag handler classes. Both Classic and Simple Tag Handlers (implemented either in Java or as tag files) can be packaged together.

The explicit web.xml map provides a explicit description of the tag libraries that are being used in a web application.

The implicit map from TLDs means that a JAR file implementing a tag library can be dropped in and used immediatedly through its stable URIs.

The use of relative URI specifications in the taglib map enables very short names in the taglib directive. For example, if the map is:


<taglib>
	<taglib-uri>/myPRlibrary</taglib-uri>
	<taglib-location>/WEB-INF/tlds/PRlibrary_1_4.tld</taglib-location>
</taglib>

					
then it can be used as:

<%@ taglib uri="/myPRlibrary" prefix="x" %>

					

Finally, the fallback rule allows a taglib directive to refer directly to the TLD. This arrangement is very convenient for quick development at the expense of less flexibility and accountability. For example, in the case above, it enables:


<%@ taglib uri="/WEB-INF/tlds/PRlibrary_1_4.tld" prefix="x" %>

					

EL expressions will be ignored by default in JSP 1.2 applications. When upgrading a web application to JSP 2.0, EL expressions will be interpreted by default. The escape sequence '\$' can be used to escape EL expressions that should not be interpreted by the container. Alternatively, the isELIgnored page directive attribute, or the <el-ignored> configuration element can be used to deactivate EL for entire translation units.

The default mode for JSP pages in a Web Application delivered using a web.xml using the Servlet 2.4 format is to evaluate EL expressions; this automatically provides the default that most applications want.

The default mode can be explicitly changed by setting the value of the el-ignored element. The el-ignored element is a subelement of jsp-property-group. It has no subelements. Its valid values are true and false.

For example, the following web.xml fragment defines a group that deactivates EL evaluation for all JSP pages delivered using the .jsp extension:


<jsp-property-group>
	<url-pattern>*.jsp</url-pattern>
	<el-ignored>true</el-ignored>
</jsp-property-group>

					
Page authors can override the default mode through the isELIgnored attribute of the page directive.

With the addition of the EL, some JSP page authors, or page authoring groups, may want to follow a methodology where scripting elements are not allowed.

The scripting-invalid element is a subelement of jsp-property-group. It has no subelements. Its valid values are true and false. Scripting is ENABLED by default. Disabling scripting elements can be done by setting the scripting-invalid element to true in the JSP configuration.

For example, the following web.xml fragment defines a group that disables scripting elements for all JSP pages delivered using the .jsp extension:


<jsp-property-group>
	<url-pattern>*.jsp</url-pattern>
	<scripting-invalid>true</scripting-invalid>
</jsp-property-group>

					

scjp 1.5 | scjp 1.6 | scwcd 1.5
Java Certifications
www.javacertifications.net