JSP built-in objects and El expressions

Source: Internet
Author: User
Tags domain lookup

Nine built-in objects
*out the output stream of the JSP to respond to the client
*page the current JSP page, its reference data type is object, that is, the following code in the Flesh object page=this;
*config it corresponds to the ServletConfig object in the
*pagecontext A top nine, this important
*requesthttpservletrequest
*responsehttpservletresponse
*exceptionthrowable
*sessionhttpsession
*applicationservletcontext

1, PageContext
* One top of nine
There are 3 domains in *servlet, and there are four fields in JSP, which is the last domain object (domain objects generally have setattribute, etc.)
ServletContext: The entire application
Session: Entire conversation (only one user in a session)
Request: A chain of requests!
PageContext: a JSP page! This field is the shared data between the current JSP page and the tags used in the current JSP page
> Domain Objects
> Agent Other domains: Pagecontext.setattribute ("xxx", "xxx", pagecontext.session_scope); response GetAttribute and remove
> Get 8 more built-in objects
> Global Search: Pagecontext.findattribute ("xxx"); From small to large, search in turn

El expression
1.jsp built-in expression language!
*jsp2.0 starts by not using Java scripts, but instead uses El expressions and dynamic tags instead of scripts!
*el instead of <%= ...%> in other words, El can only do output!
2, El expression reading four fields
*${XXX} whole domain lookup property named xxx, if not present, outputs an empty string instead of NULL
*${PAGESCOPE.XXX}, ${pagescope.xxx}, ${requestscope.xxx}, ${sessionscope.xxx}
3. JavaBean Navigation
3, El deliberately output of things are in 11 built-in objects! 10 of these are map types, that is, PageContext is not a map type
* We've learned four of
*param: The corresponding parameter, which is a map, where key is the parameter name, value is the parameter value, applicable to single-valued parameters
*paramvalues: The corresponding parameter, which is a map, where the key parameter name, value is more than one parameter value, applies to the multi-valued parameter
*header: Corresponds to the request header, which is a map, where key represents the header name, value is a single header value, applies to the single-valued request header
*headervalues: Corresponds to the request header, which is a map, where key represents the header name, value is a multi-head value
*initparam: Get the parameters in <context-param>
<context-param>
<param-name>xxx</param-name>
<param-value>XXX</param-value>
</context-param>
<context-param>
<param-name>yyy</param-name>
<param-value>YYY</param-value>
</context-param>
*cookie:map<string,cookie> type, where key is a cookie Name,value is a cookie object
*pagecontext: It is the PageContext type! ${pagecontext.request.contextpath}

================
El function library (provided by JSTL)
* Import Tag library: <%@ taglib prefix= "FN" uri= "Http://java.sun.com/jsp/jstl/functions"%>
String toUpperCase (String input)
String toLowerCase (String input)
int indexOf (String input,string substring)
Boolean contains (String input,string substring)
Boolean containsingnorecase (String input,string substring)
Boolean startsWith (String input,string substring)
Boolean endsWith (String input,string substring)
String substring (string input,int beginindex,int endIndex)
String Substringafter (string input,string substring)
String Substringbefore (string input,string substring)
String EscapeXML (String input): Escaping the "<", ">", "" "," ", and so on in input to prevent a subset of JavaScript attacks
String trim (String input)
String Replace (string input,string substringbefore,string substringafter)
String[] Split (String input,string delimiters)
int length (Object obj): Can get strings, arrays, lengths of various collections
String Join (string array[],string separator)

Custom El function Library
* Write a Java class, class can be defined 0~n methods, but must be static, with the return value of the
* Create a TLD file under the Web-inf directory
* Import tags in JSP pages

JSP built-in objects and El expressions

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.