One, expression language: Expression Language the concise way to generate dynamic content.
The most important two features of 1,jsp2.0: JSP syntax defines custom tags and expression languages.
2, to compute and output values for Java objects stored in standard locations.
* syntax is simple and effective.
* Condition output.
* Accurate access to storage objects.
* Abbreviated use of bean properties.
* Simple access to the element of the collection.
* Simple access to request parameters, cookies, and other request data.
* Automatic type conversion.
* NULL value replaces error message.
* You should use the operator of an expression language in a simple task that represents logic (representing data), avoiding the use of business logic (creating and processing data), and placing business logic in Java classes.
3,el expression Syntax:
${expression}
* Can be used in template text, custom, and standard action labels. However, it cannot be used in scripts.
4, operator
[] (array notation) or. (dot notation) operator: used to access data.
Arithmetic operator
Relational operators
logical operators
Empty operator: Detects whether the value is null or empty.
Conditional operator
Bracket operator
5, array notation [] and dot notation.:
* Array notation allows the property name to be computed during the request, and the value in parentheses can be a variable. Allows values that cannot be legal property names to be useful in the access binding and request headers.
Second, block the use of expression language
1, deactivate an expression language from the entire Web application.
Using servlet2.3 or earlier versions of the Web.xml file, the JSP2.0 expression language is automatically deactivated in the Web application.
2, deactivate an expression language from multiple JSP pages.
Use the Jsp-property-group element in Web.xml to specify the appropriate page.
<jsp-config>
<jsp-property-group>
<url-pattern>jsp Page Relative path </url-pattern>
<el-ignored>true or false</el-ignored>
</jsp-property-group>
</jsp-config>
3, deactivate the expression language in individual pages.
Use the Iselenabled property of the page directive. Can only be used in jsp1.2.
4, deactivate individual statements in an expression language.
Replace $ with & #36. If the JSP2.0 page uses an expression language and contains ${characters, use/${to output ${.
Third, block the use of standard scripting elements.
Use the Scripting-invalid child element of the Jsp-property-group element to enforce this constraint.
<jsp-config>
<jsp-property-group>
<url-pattern>jsp page relative path or *.jsp table all JSP pages are constrained </url-pattern>
<scripting-invalid>true or false</scripting-invalid>
</jsp-property-group>
</jsp-config>
Scope variables in an expression
* Scope object:
To output the value of a property in a scope, you only need to use the name of the attribute in El.
El automatically presses pagecontext,httpservletrequest,httpsession,servletcontext to search for properties from the scope object.
You can also manually use Pagescope,requestscope,sessionscope,applicationscope to specify the range of properties.
Finding the attribute calls the ToString method and returns the result of the call, without finding an empty string instead of a null or error message.
* Request Parameters:
Param: Equivalent to GetParameter (String name) method.
The paramvalues equivalent Getparametervalues (String name) method returns an array of all the values for the specified parameter names.
* Request Header:
Header and Headervalues: accesses the specified value and full value of the HTTP request header. header. Header
* Access to Cookies:
The cookie returns the cookie object rather than the value. You need to use the Value property of the cookie class to get the values. Cookie.userCookie.value
* Initialization parameters:
Initparam access to context initialization parameters. Initparam. Name of parameter
Five, JavaBean and El expressions
* A point notation is provided for access to the Bean property. The system performs reflection to analyze the intrinsic structure of the object. Gives the value of the property.
* You can nest access properties.
Vi. Accessing the collection
Allow access to different types of collections in the same way: ${attributename[entryname]}
* AttributeName An Array object, entryname as subscript.
* AttributeName implements the object of the list interface, EntryName as an index.
* AttributeName implements the object of the map interface, EntryName as key.
* The entryname in [EntryName] can be a variable.
Seven, using the function
1, define a function: Write a Java class to declare a method as static.
2, correlation function: Configuring functions in TLD using <function> elements
3, use function: ${prefix: function name (PARAM1,PARAM2, ...)}