JSP内置对象-----application

<%@page import="java.util.Enumeration"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>JSP内置对象-application</title>
</head>
<body>
<h1>application</h1>
<hr>
<%
    application.setAttribute("city", "北京");
    application.setAttribute("postcode", "100000");
    application.setAttribute("email", "beijing@163.com");
%>

    所在城市是:<%=application.getAttribute("city") %><br>
    application中的属性有:<%
        Enumeration attibutes=application.getAttributeNames();
        
        while(attibutes.hasMoreElements()){
            out.println(attibutes.nextElement()+"&nbsp;&nbsp;");
        }
    
    %><br>
    JSP(servlet)引擎名及版本号:<%=application.getServerInfo() %>

</body>
</html>

原文地址:https://www.cnblogs.com/1ming/p/9450413.html