3.5.2 REDIRECT Web page
Use the Sendredirect () method in the response object to implement one redirect to another page.
For example: Response.sendredirect ("login_ok.jsp");
3.5.3 page timed refresh or auto jump
Using the SetHeader method of response object, the timing jump or timing self-refresh of the page is realized.
(1) Response.setheader ("Refresh", "5");//Every five seconds, the page automatically refreshes
(2) Response.setheader ("Refresh", "10;url=http:www.sohu.com");
Code Exercise
<%@ 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" >
<base href= "<%=basePath%>" >
<title>response built-in objects </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" >
-
<body>
<%
Use the SetHeader method of the Response object to refresh the page every second
Response.setheader ("Refresh", "1");
Get current time
Date mydate = new Date ();
%>
<%
Display the current time
Out.println (Mydate.tolocalestring ());
%>
</body>
JSP review (Part 4)