request.jsp
来自「jakarta-taglibs」· JSP 代码 · 共 183 行
JSP
183 行
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>Jakarta REQUEST Taglib Example</title>
</head>
<body bgcolor="white">
<center>
<h1>
Jakarta REQUEST Taglib Example</h1></center>
<br>
<%@ taglib uri="http://jakarta.apache.org/taglibs/request-1.0" prefix="req" %>
<p>
<pre>
Cookies received with request:
<req:cookies id="oatmeal">
Cookie name: <jsp:getProperty name="oatmeal" property="name"/>
Comment: <jsp:getProperty name="oatmeal" property="comment"/>
Domain: <jsp:getProperty name="oatmeal" property="domain"/>
MaxAge: <jsp:getProperty name="oatmeal" property="maxAge"/>
Path: <jsp:getProperty name="oatmeal" property="path"/>
Secure: <jsp:getProperty name="oatmeal" property="secure"/>
Value: <jsp:getProperty name="oatmeal" property="value"/>
Version: <jsp:getProperty name="oatmeal" property="version"/>
</req:cookies>
See if JSESSIONID Cookie exists
<req:existsCookie name="JSESSIONID">
JSESSIONID=<req:cookie name="JSESSIONID"/>
</req:existsCookie>
<req:existsCookie name="JSESSIONID" value="false">
Cookie JSESSIONID does not exist.
</req:existsCookie>
HTTP Headers received with request:
<req:headers id="hdrs">
<jsp:getProperty name="hdrs" property="name"/> = <jsp:getProperty name="hdrs" property="header"/>
</req:headers>
See if User-Agent Header exists
<req:existsHeader name="User-Agent">
User-Agent=<req:header name="User-Agent"/>
</req:existsHeader>
<req:existsHeader name="User-Agent" value="false">
Header User-Agent does not exist.
</req:existsHeader>
GET or POST Parameters received with request:
<req:parameters id="param">
<jsp:getProperty name="param" property="name"/> = <jsp:getProperty name="param" property="value"/>
</req:parameters>
GET or POST Parameters received with request for test3:
<req:parameters id="param" name="test3">
<req:parameterValues id="pv">
<jsp:getProperty name="param" property="name"/> = <jsp:getProperty name="pv" property="value"/>
</req:parameterValues>
</req:parameters>
See if test1 parameter exists
<req:existsParameter name="test1">
test1=<req:parameter name="test1"/>
</req:existsParameter>
<req:existsParameter name="test1" value="false">
Parameter test1 does not exist.
</req:existsParameter>
See if parameter test4 equals "aabb"
<req:equalsParameter name="test4" match="aabb">
test4=<req:parameter name="test4"/>
</req:equalsParameter>
<req:equalsParameter name="test4" match="aabb" value="false">
Parameter test4 does not equal "aabb".
</req:equalsParameter>
See if test4 equals "aabb", ignoring case
<req:equalsParameter name="test4" match="aabb" ignoreCase="true">
test4=<req:parameter name="test4"/>
</req:equalsParameter>
<req:equalsParameter name="test4" match="aabb" value="false" ignoreCase="true">
Parameter test4 does not equal "aabb", ignoring case.
</req:equalsParameter>
Set an attribute named "myatt"
<req:setAttribute name="myatt">AAbb</req:setAttribute>
See if myatt attribute exists
<req:existsAttribute name="myatt">
myatt=<req:attribute name="myatt"/>
</req:existsAttribute>
<req:existsAttribute name="myatt" value="false">
Attribute myatt does not exist.
</req:existsAttribute>
Set an attribute named "myatt2" to the Header User-agent
<req:setAttribute name="myatt2"><req:header name="User-Agent"/></req:setAttribute>
See if myatt equals "aabb"
<req:equalsAttribute name="myatt" match="aabb">
myatt=<req:attribute name="myatt"/>
</req:equalsAttribute>
<req:equalsAttribute name="myatt" match="aabb" value="false">
Attribute myatt does not equal "aabb".
</req:equalsAttribute>
See if myatt equals "aabb", ignoring case
<req:equalsAttribute name="myatt" match="aabb" ignoreCase="true">
myatt=<req:attribute name="myatt"/>
</req:equalsAttribute>
<req:equalsAttribute name="myatt" match="aabb" value="false" ignoreCase="true">
Attribute myatt does not equal "aabb", ignoring case.
</req:equalsAttribute>
Now loop through all the attributes
<req:attributes id="att">
<jsp:getProperty name="att" property="name"/> = <jsp:getProperty name="att" property="value"/>
</req:attributes>
Now remove the attribute myatt
<req:removeAttribute name="myatt"/>
See if myatt attribute exists
<req:existsAttribute name="myatt">
myatt=<req:attribute name="myatt"/>
</req:existsAttribute>
<req:existsAttribute name="myatt" value="false">
Attribute myatt does not exist.
</req:existsAttribute>
<req:request id="rq"/>
Request Information:
AuthType: <jsp:getProperty name="rq" property="authType"/>
ContextPath: <jsp:getProperty name="rq" property="contextPath"/>
Method: <jsp:getProperty name="rq" property="method"/>
PathInfo: <jsp:getProperty name="rq" property="pathInfo"/>
PathTranslated: <jsp:getProperty name="rq" property="pathTranslated"/>
QueryString: <jsp:getProperty name="rq" property="queryString"/>
RemoteUser: <jsp:getProperty name="rq" property="remoteUser"/>
RequestedSessionId: <jsp:getProperty name="rq" property="requestedSessionId"/>
RequestURI: <jsp:getProperty name="rq" property="requestURI"/>
RequestURL: <jsp:getProperty name="rq" property="requestURL"/>
ServletPath: <jsp:getProperty name="rq" property="servletPath"/>
CharacterEncoding: <jsp:getProperty name="rq" property="characterEncoding"/>
ContentLength: <jsp:getProperty name="rq" property="contentLength"/>
ContentType: <jsp:getProperty name="rq" property="contentType"/>
Protocol: <jsp:getProperty name="rq" property="protocol"/>
RemoteAddr: <jsp:getProperty name="rq" property="remoteAddr"/>
RemoteHost: <jsp:getProperty name="rq" property="remoteHost"/>
Scheme: <jsp:getProperty name="rq" property="scheme"/>
ServerName: <jsp:getProperty name="rq" property="serverName"/>
ServerPort: <jsp:getProperty name="rq" property="serverPort"/>
</pre>
<br><br>
<p>
IsSecure?
<req:isSecure>Session is using HTTPS.</req:isSecure>
<req:isSecure value="false">Session is not using HTTPS.</req:isSecure>
<br><br>
<p>
IsSessionFromCookie?
<req:isSessionFromCookie>Session is using a cookie.</req:isSessionFromCookie>
<req:isSessionFromCookie value="false">Session is not using a cookie.</req:isSessionFromCookie>
<br><br>
<p>
IsSessionFromURL?
<req:isSessionFromUrl>Session is using a URL.</req:isSessionFromUrl>
<req:isSessionFromUrl value="false">Session is not using a URL.</req:isSessionFromUrl>
<br><br>
<p>
IsSessionValid?
<req:isSessionValid>Session is valid.</req:isSessionValid>
<req:isSessionValid value="false">Session is not valid.</req:isSessionValid>
<br><br>
<p>
IsUserInRole "admin"?
<req:isUserInRole role="admin">User is in role admin.</req:isUserInRole>
<req:isUserInRole role="admin" value="false">User is not in role admin.</req:isUserInRole>
<br><br>
Log a message to the servlet context log.
<req:log>
Test of logging to your servlet context log by the request taglib.
</req:log>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?