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"/>
常用的方法
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"/>