This is a built-in objects can directly use it, do not need to go to the statement.
1, reads the page context:
(1) pageContext objects:
Gets a URL and URI:
<body> URI:${pageContext.request.requestURI};<br> URL:${pageContext.request.requestURL};<br> </body>
application:
Gets the name of the dynamic web application:
<body>
${pageContext.request.contextPath}
</body>
Operating results for the name of the web application.
<center> <h3>注册</h3> <form action="${pageContext.request.contextPath}/el.jsp" method="post"> 用户名:<input type="text" name="account" size="12"><br><br> 密码:<input type="password" name="password" size="12"> <input type="submit" value="注册"> <input type="reset" value="取消"> </form> </center>
Put it into action, even if the project name is changed, is still able to function properly.
Which pageContext.request to get the request object.
2, four domains (not an object):
(2)pageContext域,(3)request域,(4)session域,(5)application域:pageScrop、requestScrop、sessionScrop、applicationScrop。
3, read client form or query string parameters:
(6) param: get a single parameter:
Gets the data:
<body bgcolor="aqua"> <center> <h3>注册</h3> <form action="${pageContext.request.contextPath}/el.jsp" method="post"> 用户名:<input type="text" name="account" size="12"><br><br> 密码:<input type="password" name="password" size="12"> <input type="submit" value="注册"> <input type="reset" value="取消"> </form> </center>
<body>
account name: $ {param.account}
Password: $ {param.password}
</ body>
(7) paramValues get form data.
4: the read request request header:
(8) header: acquiring a single data:
</head> <body bgcolor="#7fffd4"> ${header["User-Agent"]}<br> ${header.Host} </body>
(9) headerValues: acquiring a plurality of data.
5: reading (10) Cookie:
(1) create a JSP to create a Cookie:
<body> <% Cookie cookie=new Cookie("name","zhai"); response.addCookie(cookie); %> </body>
(2) obtain information in the Cookie:
${cookie.name.value}
6, reads initialization parameters:
(1) first initialization data arranged in web.xml:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <context-param> <param-name>zhai</param-name> <param-value>1997</param-value> </context-param> </web-app>
(2) to obtain:
<body bgcolor="#7fffd4"> ${initParam.zhai} </body>