El Technology
El (express lanuage) expression can be embedded inside the JSP page, reduce the writing of JSP script, El appears to replace the JSP page script writing.
El's main function is to extract data from the field, format ${el expression}
- El gets the value in the PageContext domain: ${pagescope.key};
- El obtains the value in the request domain: ${requestscope.key};
- El gets the value in the session field: ${sessionscope.key};
- El gets the value in the application domain: ${applicationscope.key};.
- El obtains a value from four domains ${key};
The same is obtained from the PageContext domain, the request domain, the session field, the application domain, and is not searched backwards after being fetched in a domain
El Built-in (11) Objects
1) receive the parameters of the transmitted
Param and paramvalues//param. Name of the parameter
Equivalent to Request.getparameter () request.getparametervalues ()
2) Get Request header information
Header,headervalues//header. Request Header Parameters
Equivalent to Request.getheader (name)
3) Get Global initialization parameters
Initparam//Initparam. Name of parameter
Equivalent to This.getservletcontext (). Getinitparameter (name)
Web. xml file format
<context-param> <param-name>abc</param-name> <param-value> xin brother Bang Bang da! </param-value></context-param>
4) Cookies
Cookies//Cookie.name,cookie.value
Equivalent to Request.getcookies ()---cookie.getname ()---cookie.getvalue ()
5) PageContext
PageContext.request.contextPath//Get the current web app name
Equivalent
<%=pagecontext.getrequest () .getcontextpath%> This code cannot be implemented
Other features: Get the other eight big objects
Pagecontext.request/response/cookie/session
Name |
Type |
Describe |
Out |
Javax.servlet.jsp.JspWriter |
For page output |
Request |
Javax.servlet.http.HttpServletRequest |
Get user request information, |
Response |
Javax.servlet.http.HttpServletResponse |
Response information from the server to the client |
Config |
Javax.servlet.ServletConfig |
Server configuration, can get initialization parameters |
Session |
Javax.servlet.http.HttpSession |
Information to save the user |
Application |
Javax.servlet.ServletContext |
Shared information for all users |
Page |
Java.lang.Object |
Refers to an instance of the current page-converted Servlet class |
PageContext |
Javax.servlet.jsp.PageContext |
JSP's page container |
exception |
Java.lang.Throwable |
Represents an exception that occurs on a JSP page and does not work in the error page |
Determines whether the empty
${empty User}
Jstl Technology
JSTL (JSP standard tag Library), JSP standards tag libraries, can be embedded in the JSP page using the form of tags to complete business logic and other functions. The purpose of the JSTL is to replace the script code in the JSP page, as is the case with El. The JSTL standard standard Tag Library has 5 sub-libraries, but as it develops, it is often the core library core that is used today.
Tag Library |
The URI of the tag library |
Prefix |
Core |
Http://java.sun.com/jsp/jstl/core |
C |
i18n |
Http://java.sun.com/jsp/jstl/fmt |
Fmt |
Sql |
Http://java.sun.com/jsp/jstl/sql |
Sql |
Xml |
Http://java.sun.com/jsp/jstl/xml |
X |
Functions |
Http://java.sun.com/jsp/jstl/functions |
Fn |
A. Download two jar packages for tag library
B. Importing a tag library
<%@ taglib uri= "Http://java.sun.com/jsp/jstl/core" prefix= "C"%>
1. If condition judgment
Format:
<c:if test= "condition judgment" > label
Where test is the condition that returns a Boolean, there is no else in Jstl.
2. For Loop
Format:
<c:forEach> tags
There are two combinations of modes of use:
The first form of
The second form of
<c:foreach items= "${strlist}" var= "str" >${STR}<br/></c:foreach>
Java EE development model
Model in the development process summed up the "routines", summed up a set of conventional design patterns
MVC pattern
M:model---Model JavaBean: encapsulating data
V:view-----View JSP: Simply display the page
C:controller----Controller Servelt: Get data--encapsulate data--pass data--Assign the displayed JSP page
Java EE three layer architecture
Web tier: Interacting with clients
Service layer: Complex business processing
DAO Layer: Interacting with a database
The three-tier architecture is embodied through the package structure in the development practice
Javaweb--el Technology, JSTL Technology, Java EE development model