EL Scripting Configuration and Support: For a single JSP page, you can use the definition PAGE instruction to set whether the JSP page supports EL. The default is to support EL (if you want a page does not support EL, set it to iSelignored = true;
<% @ page islignored = "true | false"%> For the entire JSP application, you want to modify the web.xml configuration (Tomcat5.0.16 is supported by default);
El-ignored>
jsp-proteTy-group>
Arithmetic Operator Demo: The following is a list of EL operators, where EMPTY can check if a value is empty
Operator Description Operator Description Plus> or GT is greater than-reduction <= or LE is less than or equal to * multiplying> = or GE greater than or equal to / or DIV except && or AND logic and% or MOD mode (surplus) || or logic Or == or = equal to! = Or! = Not equal to EMPTY check whether it is a null value EL arithmetic expression operation result EL relationship calculation expression calculation result $ {1} 1 $ {1 <2} True $ {1 2} 3 $ {1 LT 2} True $ {1.2 2.3} 3.5 $ {1> (4/2)} False $ {- 4 - 2} -6 $ {4.0> = 3} True $ {21 * 2} 42 $ {4.0 ge 3} True $ {10% 4} 2 $ {100.0 EQ 100 } TRUE $ {10 MOD 4} 2 $ {(10 * 10)! = 100} false $ {(1 == 2)? 3: 4} 4 $ {(10 * 10) NE 100} false implicit object data Demonstration: The EL expression defines 11 implied objects. It can be easily read to session, cookie, httpheader, user submission form (PARAM), etc. with this 11 objects. Implicit Object Content ApplicationsCope Application SCOPED Variable Composition Collection Cookie All cookies Composed of Collections HEADER HTTP Request Headquarters, String HeaderValues HTTP Request Headquarters, String Set InitParam All Application Parameter Many Set PageContext Current Page Javax.servlet.jsp.PageContext Objects All Objects Page range All Objects All Request parameter strings Compose Paramvalues All RequestScope All Request Scope Objects SessionScope All Session Siders Collection The following is an example EL expression operation result for the HTTP access header data and user submission data $ {header ["host"]} Get host value of the HTTP connection header $ {header ["accept"]} here HTTP The ACCEPT value of the header $ {header ["User-agent"]} This is obtained here that the user-agent value below can read the information submitted by the user. Suppose the user submit information is? Name = MyName & Alies = now.net.cn (There are two access methods, one is to use [] to access, and the other is to use "" to access, the two access effects are the same.) $ {Param ["name"]} myname $ { Param.name} MyName $ {param ["alies"]} Now.net.cn $ {param.alies} Now.net.cn Definition and Use Function Expression Language Allows that you define functions that can be called in the expression. The function must be written as a public static method in the public class. Also map files into the TLD flag library file. To illustrate the use of functions, we will give a simple example and add two numbers. First, you must write a Java method code for two numbers, as shown in Code Example 3, define a static method, which receives two string parameters, parsing them into integers and returns them. Sample file: compute.java package jsp2.examples.el; import java.util. *; Public class compute { Public Static Int Add (String X, String Y) { INT A = 0; INT b = 0; Try { A = integer.parseint (x); B = integer.Parseint (Y); } catch (exception e) {} RETURN A B; } } After using JAVAC to compile this code successfully, the next step will map the signature of the function to the label library. Code Example 4 illustrates how to map the ADD function to a class containing function implementations and function signs. The following will be added to where this code is added. Configuration Tag Library Description File Function Descriptor function-class> Add (java.lang.string, java.lang.string) function-signature> function> Now we can write a JSP page to use this function. Code Example 5 is a form that contains two fields, and the user enters two numbers and presses the "summation" button, which will call the above function and add the two numbers, the result is displayed in the same page. Code Example 5: Math.jsp <% @ taglib prefix = "My" URI = "http://jakarta.apache.org/tomcat/jsp2-example-taglib%>
Head>