can do the JSP operation. In this I have customized the dicselect tag so that I can use a custom label every time I use the dropdown box, eliminating the step of repeating the drop-down box. Here you have to say. Tag and. tld files. The former belongs to the JSP file and the latter is the XML file.1. For tag filesThe tags are a directory, there are several tag files.However, when using 2. for TLD filesA
development objects
11 implicit objects are defined in EL Expression Language. Using these implicit objects, you can easily obtain some common objects in web development and read the data of these objects.
Syntax: $ {implicit object name}: Get Object Reference
Note:
When testing headerValues, if the header contains "-", for example, Accept-Encoding, headerValues ["Accept-Encoding"]
For example, $ {cookie. key} is the cookie object. For example, $ {cookie. key. name} or $ {cookie. key. val
1. To develop a custom behavior, you need to use a series of classes and interfaces called tag extension mechanisms in JSP1.1 specifications ). All interfaces and classes required to implement the tag handler are defined in the javax. servlet. jsp. tagext package. The two main interfaces are Tag and BodyTag. To make the development of the tag handler easier, the API defines two supported classes: TagSupport and BodyTagSupport. These two classes provide the default implementation for the above tw
Custom tags can be used in JSP pages starting with jsp1.1, and using custom tags not only enables code reuse, but also makes JSP code more concise. The Simpletag interface and its implementation class Simpletagsupport are also added to the Jsp2.0 label extension API.tag Extension API hierarchy:An explanation of the TLD file elements:Each custom label must be declared in the TLD file, and theTLD file is simp
introduces the tag's parent tag. (Not required)
The following is a custom label class: (a java class that prints the content of the label body multiple times)
Package online. mytag; import java. io. IOException; import javax. servlet. jsp. jspException; import javax. servlet. jsp. jspWriter; import javax. servlet. jsp. tagext. simpleTagSupport; public class PrintTag extends SimpleTagSupport {private int count; // the field here must be in. if you use the
1. If labelIftag.java filePackage Com.rk.tag;import Java.io.ioexception;import Javax.servlet.jsp.jspexception;importJavax.servlet.jsp.tagext.jspfragment;import Javax.servlet.jsp.tagext.simpletagsupport;public class IfTag extends Simpletagsupport{private boolean test;public void Settest (Boolean test) {this.test = test;}@Overridepublic void Dotag () throws Jspexception, ioexception{//determines whether to output the label body content if (test = = True), based on the return value of the test {//j
The last article is about the core tags commonly used in Jstl, this article describes the use of JSTL custom tags. Remember when learning JS, we learned the jquery framework, at the same time learning to construct their own JS library, and then to call their own JS library, it is like according to their own needs of a cohesive function, we create a function, then call this function. In learning the Java EE Specification jstl tag section, we can also construct our own tag library according to our
the code and place the class file in the class library of the program. Then, you will need a Tag Library Descriptor (TLD) file, which is an XML file to match your operation name and the corresponding Tag manager class.
MyAction
com.myactions.MyActionTag
(whatever)
myData
Related Trialware◆ DbUtils (Apache Software Foundation)◆ IBM Informix JDBC Driver (IBM)◆ MySQL Connector/J 3.0 (MySQL AB)◆ SQL4X Manager J 2.2 (MacosGuru)◆ Informix D
type set
Execute operations in EL expressions
Syntax: $ {operational expression}. EL expressions support the following operators:
Empty OPERATOR: checks whether the variable is null or "null"Binary Expression: $ {user! = Null? User. name: ""}
Obtain objects in Web Development
11 implicit objects are defined in EL Expression Language. Using these implicit objects, you can easily obtain some common objects in web development and read the data of these objects.Syntax: $ {implicit object name}: Ge
Tag library~ Write a class that contains a method to be called by El, this method must be a static method~ Write a TLD file in which to describe the static method to be called ~ taglib directives in JSP pages to introduce TLD files into the current JSP page so that the described method can be called in the JSP page 3.JSTL: !! !! !! The !! 4. Custom Label Technology: Tags: jsp can be used to gene
Custom labels can greatly facilitate the authoring of our page controls, and can achieve a lot of unified management.0, first need to introduce the support of custom label jar package, there are two ways,One is to introduce dependencies directly into Maven: The other is directly with your Tomcat JSP-API.You can take one of two ways.1. Custom method labels via TLD filesThis usage of TLD allows us to u
: ""}-----Ternary operator3, EL 11 built-in objectsPagescope Requestscope sessionscope applicationscope Four data range, used to take a valuePageContext Current JSP context-----${pagecontext.request.contextpath}${param.name} equivalent to Request.getparameter ("name")${paramvalues.hobby} equivalent to Request.getparametervalues ("hobby")${header.referer} equivalent to Request.getheader ("Referer")${headervalues["Accept-encoding"} is equivalent to Request.getheaders ("accept-encoding")${initparam
This example describes the use of JSP custom tags. Share to everyone for your reference. Specifically as follows:
There is a mechanism in JSP that allows you to insert markup similar to HTML in a JSP page. This article describes the basic concepts and composition of JSP custom tags, and how to develop and apply JSP custom tags.
What is a tag
Using the HTML language we can edit our web pages like this:
Here we call
In the example above,
The process of the JSP ser
JSP page. Here, the Java code is moved out of the scriptlet and placed in a custom label:
The date and time at the server are:
In this example,
Create a user-defined label processor
Creating a user-defined label processor requires more than a certain amount of work for a scriptlet because of this Java class, and you have to write a descriptor file for him in the TLD format (described in the next section). The following class D
classes are invoked in El expressions, and the static method of this Java class needs to be described in the TLD file before it can be invoked by an El expression.
El custom functions are used to extend the functionality of El expressions, allowing El expressions to perform the functions that ordinary Java program code can accomplish.
1.5. EL function Development Steps
In general, the development and application of El Custom functions consists of
Tag Library taglib
tags are defined and distributed in a structure called a tag library, which is a collection of meta information and classes:
1. Label Processor: Java class that implements custom label functions.
2. Tag additional information (TEI): Provides a side series to the JSP container to confirm the label attributes and the class that created the variable.
3. Tag Library Descriptor (TLD): An XML document that describes the properties of
Java class can only be called in an El expression, and the static method of the Java class needs to be described in the TLD file before it can be called by an El expression.The El Custom function is used to extend the functionality of the El expression, allowing the El expression to do what ordinary Java program code can do.1.5. EL function Development StepsIn general, the development and application of El Custom functions consists of the following t
, and the static method of the Java class needs to be described in the TLD file before it can be called by an El expression.The El Custom function is used to extend the functionality of the El expression, allowing the El expression to do what ordinary Java program code can do.1.5. EL function Development StepsIn general, the development and application of El Custom functions consists of the following three steps:1. Write a static method of a Java clas
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.