jsp response

response
常用的方法
public  void   addCookie(Cookie  cookie) 向客户端增加cookie
<%
Cookie c1 = new Cookie("lxh","LiXingHua") ;
Cookie c2 = new Cookie("mldn","www.MLDNJAVA.cn") ;
c1.setMaxAge(100) ;
c2.setMaxAge(100) ;
response.addCookie(c1) ;
response.addCookie(c2) ;
%>
<%
Cookie c[] = request.getCookies() ; // 取得客户端的全部Cookie
System.out.println(c) ;
for(int x=0;x<c.length;x++){
%>
<h3><%=c[x].getName()%> --> <%=c[x].getValue()%></h3>
<%
}
%>
public    void setHeader(String name,String value)设置回应的头信息
<%
response.setHeader("refresh","2") ; // 页面2秒一刷新
%>
<h3>已经访问了<%=count++%>次!</h3>
<h3>3秒后跳转到hello.htm页面,如果没有跳转请按<a href="hello.htm">这里</a>!</h3>
<%
response.setHeader("refresh","3;URL=hello.htm") ; // 3秒后跳转到hello.htm页面
%>
public void  sendRedirect(String location)throws IOException 页面跳转
response.sendRedirect("hello.htm") ;
<jsp:forward page="hello.htm"/>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值