JSP review (Part 4)

Source: Internet
Author: User

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" >

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 ());

JSP review (Part 4)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.