1. 程式人生 > >Rquest對象代碼練習

Rquest對象代碼練習

thead path ade styles -- odin name com script

1.代碼練習

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP ‘index.jsp‘ starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>

<body>
<font color="blue">表單提交的信息:</font><br>
輸入的第1個數據是:<%=request.getParameter("shuju1") %><br>
輸入的第2個數據是:<%=request.getParameter("shuju2") %><br><br>
<font color="red">客戶端信息:</font> <br>
客戶端協議名和版本號:<%=request.getProtocol() %><br/>
客戶機名:<%=request.getRemoteHost() %> <br>
客戶機的IP地址:<%=request.getRemoteAddr() %><br>
客戶提交信息的長度:<%=request.getContentLength() %><br/>
客戶提交信息的方式:<%=request.getMethod() %><br>
HTTP頭文件中的Host值:<%=request.getHeader("Host") %><br>
服務器名 :<%=request.getServerPort() %><br>
服務器端口號:<%=request.getServerPort() %><br>
接受客戶提交信息的頁面:<%=request.getServletPath() %><br/>
</body>

運行截圖

技術分享

Rquest對象代碼練習