當(dāng)前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
(二十):response 对象 (JSP学习第六天)
生活随笔
收集整理的這篇文章主要介紹了
(二十):response 对象 (JSP学习第六天)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
response 對象
主要作用是對客戶端的請求進行回應(yīng),將WEB服務(wù)器的處理結(jié)果發(fā)回客戶端,
response對象屬于javax.servlet.http.HttpServletResponse接口的實例
HttpServletResponse接口定義如下:
public interface HttpServletResponse extends ServletResponse
設(shè)置頭信息
設(shè)置定時刷新頭信息response_demo01.jsp
<%@ page language="java" contentType="text/html" pageEncoding="GBK"%> <html> <title>測試</title> <body> <%! int count=0; %> <%response.setHeader("refresh","2"); %> <h3>你已經(jīng)訪問了<%=count++%>次</h3> </body> </html>3秒鐘跳轉(zhuǎn)到其他頁面 response_demo02.jsp
<%@ page language="java" contentType="text/html" pageEncoding="GBK"%> <html> <head> <title>測試</title> </head> <body> <h3>3秒后跳轉(zhuǎn)到hello.html頁面,如果沒有請按<a href="hello.html">這里</a></h3> <%response.setHeader("refresh","3;url=hello.html"); %> </body> </html>跳轉(zhuǎn)之后瀏覽器地址已經(jīng)發(fā)生改變,這種定時跳轉(zhuǎn)屬于客戶端跳轉(zhuǎn),
還可以使用html頁面進行頁面的跳轉(zhuǎn)response_demo03.html
<html> <head> <title>測試</title> </head> <META HTTP-EQUIV="refresh" CONTENT="3;URL="hello.html"> <body> <h3>3秒后跳轉(zhuǎn)到hello.html頁面,如果沒有請按<a href="hello.html">這里</a></h3> </body> </html>只有當(dāng)一個頁面沒有jsp代碼的是才用html形式的設(shè)置跳轉(zhuǎn)的頭信息(說得有點簡單,初學(xué)者就是這樣,暫且就這么說吧,以后有時間繼續(xù)補充)
轉(zhuǎn)載于:https://www.cnblogs.com/techstan/archive/2011/10/06/2199941.html
總結(jié)
以上是生活随笔為你收集整理的(二十):response 对象 (JSP学习第六天)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 中国建设银行(2011.11.19南京大
- 下一篇: 【转】主要空间数据挖掘方法