SoFunction
Updated on 2025-04-07

jsp base tag and meta tag learning summary


<%@ page language="java" import=".*" pageEncoding="utf-8"%>
<!-- Define the encoding of jsp, and the imported java file -->
<%
String path = ();
//Get the current project name.
String basePath = ()+"://"+()+":"+()+path+"/";
//The basic url of the current project.
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!-- Current http://current host: port/project name base tag defines the absolute path to which the current jsp belongs -->
<base href="<%=basePath%>">
<!-- Define the title of the current jsp page. The title defined here will be displayed on the tab of our browser. -->
<title>hello word</title>

<!-- The function of the meta tag is:

meta is an auxiliary tag in the head area of ​​the html language. Maybe you think these codes are optional. In fact, if you can use the meta tag,
It will bring you unexpected effects. The functions of meta tags include: search engine optimization (SEO), defining the language used by the page, automatically refreshing and referring to
To the new page, realize the dynamic effect of web page conversion, control page buffering, web page rating evaluation, control the window displayed on the web page, etc.!

The composition of meta tags: There are two attributes in the meta tag, name attribute, respectively, http-equiv attribute,
Different attributes have different parameter values, and these different parameter values ​​realize different web page functions.

1. Name attribute

The name attribute is mainly used to describe the web page. The corresponding attribute value is content. The content in the content is mainly
It is convenient for search engine robots to find information and classify information.

The syntax format of the name attribute of the meta tag is:

<meta name="parameter"content="specific parameter value">.

The name attribute mainly has the following parameters:

A. Keywords (keywords)

Description: keywords are used to tell search engines what keywords are on your web page.

Example: <meta name="keywords"content="science,education,culture,politics,ecnomics,relationships,entertaiment,human">

B. Description (Website content description)

Description: Description is used to tell search engines the main content of your website.

Example: <meta name="description"content="Thispageisaboutthemeaningofscience,education,culture.">

C. robots (robot guide)

Description: robots are used to tell search robots which pages need indexes and which pages do not need indexes.

The parameters of content are all, none, index, noindex, follow, nofollow. The default is all.

Example: <metaname="robots"content="none">

D. Author(author)

Description: Label the author of the web page

Example: <metaname="author"content="root,root@">

2. http-equiv attribute

As the name suggests, http-equiv is equivalent to the file header of http. It can pass back some useful information to the browser to help display the web page content correctly and accurately. The corresponding attribute value is content, and the content in the content is actually the variable value of each parameter.

The syntax format of the http-equiv attribute of the meta tag is:

<meta http-equiv="parameter"content="parameter variable value">;

Among them, the http-equiv attribute mainly has the following parameters:

A. Expires (term)

Note: It can be used to set the expiration time of the web page. Once the web page expires, it must be retransmitted to the server.

Usage: <meta http-equiv="expires" content="Fri,12Jan200118:18:18GMT">

Note: GMT's time format must be used.

B. Pragma (cache mode)

Note: The browser is prohibited from accessing page content from the cache on the local computer.

Usage: <meta http-equiv="Pragma" content="no-cache">

Note: This setting will allow visitors to browse offline.

C. Refresh (refresh)

Description: Automatically refresh and point to a new page.

Usage: <meta http-equiv="Refresh" content="2;URL=https://"> (Note the quotes afterwards, before the seconds and after the URL respectively)

Note: 2 of them means that you will automatically refresh to the URL URL after staying for 2 seconds.

D. Set-Cookie (cookie settings)

Note: If the web page expires, the saved cookies will be deleted.

Usage: <meta http-equiv="Set-Cookie" content="cookievalue=xxx;expires=Friday,12-Jan-200118:18:18GMT; path=/">

Note: GMT's time format must be used.

E. Window-target (display window settings)

Description: Force the page to be displayed as a separate page in the current window.

Usage: <meta http-equiv="Window-target" content="_top">

Note: Used to prevent others from calling their own pages in the framework.

F, content-Type (display character set settings)

Description: Set the character set used on the page.

Usage: <metahttp-equiv="content-Type"content="text/html;charset=gb2312">

G, content-Language (display language settings)

Usage: <meta http-equiv="Content-Language" content="zh-cn"/>

H, Cache-Control specifies the caching mechanism that requests and responses follow.
Cache-Control specifies the caching mechanism that requests and responses follow. Setting Cache-Control in a request message or response message will not modify
Another cache processing process during message processing. The cache instructions during request include no-cache, no-store, max-age, max-stale, min-fresh, on

ly-if-cached, the instructions in the response message include public, private, no-cache,
no-store、no-transform、must-revalidate、proxy-revalidate、max-age。

The meaning of the command in each message is as follows
Public indicates that the response can be cached by any cache area
Private indicates that the entire or partial response message of a single user cannot be processed by a shared cache.
This allows the server to describe only partial response message for the user, which is invalid for other users' requests
no-cache indicates that the request or response message cannot be cached
no-store is used to prevent important information from being published unintentionally. Sending in a request message will make neither the request nor the response message use cache.
max-age indicates that the client can receive responses whose lifetime is not greater than the specified time (in seconds)
min-fresh indicates that the client can receive a response whose response time is less than the current time plus the specified time
max-stale indicates that the client can receive a response message that has expired the timeout period. If the value of the max-stale message is specified,
The client can then receive a response message that exceeds the specified value after the timeout.

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

</head>

<body>
<!-- Add the code I need can be java,js,jstl,el -->

</body>
</html>