天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

JSP內置對象:Request和Response的簡單介紹及使用


JSP內置對象之request對象
客戶端的請求信息被封裝在request對象中,通過它才能了解到客戶的需求,然后做出響應。它是HttpServletRequest類的實例。
序號 方 法 說 明
1 object getAttribute(String name) 返回指定屬性的屬性值
2 Enumeration getAttributeNames() 返回所有可用屬性名的枚舉
3 String getCharacterEncoding() 返回字符編碼方式
4 int getContentLength() 返回請求體的長度(以字節數)
5 String getContentType() 得到請求體的MIME類型
6 ServletInputStream getInputStream() 得到請求體中一行的二進制流
7 String getParameter(String name) 返回name指定參數的參數值
8 Enumeration getParameterNames() 返回可用參數名的枚舉
9 String[] getParameterValues(String name) 返回包含參數name的所有值的數組
10 String getProtocol() 返回請求用的協議類型及版本號
11 String getScheme() 返回請求用的計劃名,如:http.https及ftp等
12 String getServerName() 返回接受請求的服務器主機名
13 int getServerPort() 返回服務器接受此請求所用的端口號
14 BufferedReader getReader() 返回解碼過了的請求體
15 String getRemoteAddr() 返回發送此請求的客戶端IP地址
16 String getRemoteHost() 返回發送此請求的客戶端主機名
17 void setAttribute(String key,Object obj) 設置屬性的屬性值
18 String getRealPath(String path) 返回一虛擬路徑的真實路徑
復制代碼 代碼如下:
< %@ page contentType="text/html;charset=gb2312"%>
< %request.setCharacterEncoding("gb2312");%>
< html>
< head>
< title>request對象_例1< /title>
< /head>
< body bgcolor="#FFFFF0">
< form action="" method="post">
< input type="text" name="qwe">
< input type="submit" value="提交">
< /form>
請求方式:< %=request.getMethod()%>< br>
請求的資源:< %=request.getRequestURI()%>< br>
請求用的協議:< %=request.getProtocol()%>< br>
請求的文件名:< %=request.getServletPath()%>< br>
請求的服務器的IP:< %=request.getServerName()%>< br>
請求服務器的端口:< %=request.getServerPort()%>< br>
客戶端IP地址:< %=request.getRemoteAddr()%>< br>
客戶端主機名:< %=request.getRemoteHost()%>< br>
表單提交來的值:< %=request.getParameter("qwe")%>< br>
< /body>
< /html>  
< %@ page contentType="text/html;charset=gb2312"%>
< %request.setCharacterEncoding("gb2312");%>
< %@ page import="Java.util.Enumeration"%>
< html>
< head>
< title>request對象_例2< /title>
< /head>
< body bgcolor="#FFFFF0">
< form action="" method="post">
用戶名:< input type="text" name="username">   
密 碼:< input type="text" name="userpass">   
< input type="submit" value="進入" >
< /form>
< % 
String str=""; 
if(request.getParameter("username")!=null && request.getParameter("userpass")!=null){ 
Enumeration enumt = request.getParameterNames(); 
while(enumt.hasMoreElements()){ 
str=enumt.nextElement().toString(); 
out.println(str ":" request.getParameter(str) "< br>"); 


%>
< /body>
< /html>  
< %@ page contentType="text/html;charset=gb2312"%>
< %request.setCharacterEncoding("gb2312");%>
< html>
< head>
< title>request對象_例3< /title>
< /head>
< body bgcolor="#FFFFF0">
< form action="" method="post">
擅長:< input type="checkbox" name="cb" value="ON1">VC   
< input type="checkbox" name="cb" value="ON2">Java  
< input type="checkbox" name="cb" value="ON3">DELPHI  
< input type="checkbox" name="cb" value="ON4">VB  
< br>
< input type="submit" value="進入" name="qwe">
< /form>
< % 
if(request.getParameter("qwe")!=null ){ 
for(int i=0;i< request.getParameterValues("cb").length;i ){ 
out.println("cb" i ":" request.getParameterValues("cb")[i] "< br>"); 

out.println(request.getParameter("qwe")); 

%>
< /body>
< /html>

JSP內置對象之response對象
response對象包含了響應客戶請求的有關信息,但在JSP中很少直接用到它。它是HttpServletResponse類的實例。
序號 方 法 說 明
1 String getCharacterEncoding() 返回響應用的是何種字符編碼
2 ServletOutputStream getOutputStream() 返回響應的一個二進制輸出流
3 PrintWriter getWriter() 返回可以向客戶端輸出字符的一個對象
4 void setContentLength(int len) 設置響應頭長度
5 void setContentType(String type) 設置響應的MIME類型
6 sendRedirect(Java.lang.String location) 重新定向客戶端的請求

jsp技術JSP內置對象:Request和Response的簡單介紹及使用,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 在线播放免费人成毛片视频 | 女生下面免费看 | 国产成人在线观看免费网站 | 扒开老师大腿猛进AAA片 | 久久6699精品国产人妻 | 办公室的秘密2中文字幕 | 优菈的乳液狂飙天堂W98 | YELLOW免费观看2019 | 亚洲婷婷天堂综合国产剧情 | 试看2分钟AA片 | 疯狂小护士 | 亚洲高清视频网站 | 欧亚一卡二卡日本一卡二卡 | 久久综合九色 | 亚洲色综合中文字幕在线 | 日本工口生肉全彩大全 | 国产成人精品永久免费视频 | 亚洲人人为我我为人人 | 伊人电院网 | 91涩涩视频 | 亚洲AV永久无码精品老司机蜜桃 | 波多野结衣 无码片 | 日本zljzljzlj精品 | 黄色免费网址在线观看 | 97影院理论午夜伦不卡偷 | 国产露脸150部国语对白 | 人人碰79免费视频 | 小夫妻天天恶战 | 亚洲综合无码一区二区 | 好看AV中文字幕在线观看 | 国产精品99久久久久久人韩国 | 国产精品亚洲AV毛片一区二区三区 | 一天不停的插BB十几次 | 国产国语在线播放视频 | 最近中文字幕完整版免费 | 色一情一乱一伦一区二区三区 | 黄色a三级三级三级免费看 黄色a三级免费看 | 黑人巨大两根一起挤进欧美 | 最近韩国HD免费观看国语 | 日本丝袜护士 | 97人人碰免费视频公开 |