Java Tutorial/JSP/HTTP Header
Содержание
Get HTTP Header Information
index.jsp
<source lang="java">
<HTML>
<HEAD> <TITLE>Getting Header Data</TITLE> </HEAD> <BODY>
Getting Header Data
<FORM ACTION="basic.jsp" METHOD="POST"> <INPUT TYPE="submit" VALUE="Submit"> </FORM> </BODY>
</HTML></source>
Print out HTTP Request Headers
<source lang="java">
<%--
Copyright (c) 2002 by Phil Hanna All rights reserved. You may study, use, modify, and distribute this software for any purpose provided that this copyright notice appears in all copies. This software is provided without warranty either expressed or implied.
--%> <%@ page import="java.util.*" %> <html>
<head> <title>Echo</title> <style> <jsp:include page="style.css" flush="true"/> </style> </head> <body>
HTTP Request Headers Received
<%= name %> | <%= value %> |
</body>
</html> <%!
private String normalize(String value) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); sb.append(c); if (c == ";") sb.append("
"); } return sb.toString(); }
%></source>