JSP Request. Getheaders () method: returns all the values of the request header with the specified name
•
Java
getHeaders(String name)
Example
<% Enumeration cts = request.getHeaders("accept-encoding"); while(cts.hasMoreElements()){ out.println("accept-encoding="+cts.nextElement()+"<br>"); } %>
Typical application
<div style="width:600px"> <ul style="line-height:24px"> <li>客户使用的协议:<%=request.getProtocol()%> <li>客户端发送请求的方法:<%=request.getmethod()%> <li>客户端请求路径:<%=request.getContextPath()%> <li>客户机IP地址:<%=request.getRemoteAddr()%> <li>客户机名称:<%=request.getRemoteHost()%> <li>客户机请求端口号:<%=request.getRemotePort()%> <li>接受客户信息的页面:<%=request.getServletPath()%> <li>获取报头中User-Agent值:<%=request.getHeader("user-agent")%> <li>获取报头中accept值:<%=request.getHeader("accept")%> <li>获取报头中Host值:<%=request.getHeader("host")%> <li>获取报头中accept-encoding值:<%=request.getHeader("accept-encoding")%> <li>获取URI:<%=request.getRequestURI()%> <li>获取URL:<%=request.getRequestURL()%> </ul> </div>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码