来自「一些jsp源代码 内含完整jsp程序 希望大家喜欢!!!!!!!!!!!!!」· 代码 · 共 34 行

TXT
34
字号
范例ApplicationObject.jsp源代码:
001<html>
002<head>
003<title>Application对象示例</title>
004</head>
005<body>
006<p align="left"><font size="5">Application对象示例</font></p>
007<hr>
008<%
009   //首先通过getAttribute方法获取数据并赋给变量counter
010   String counter=(String)application.getAttribute("counter");
011   //再来判断Application对象中用于存储计数值是否为空
012     
013   if(counter!=null)
014   {
015      //如果不为空的话,并将数据从字符串型转换为整型
016      int int_counter=Integer.parseInt(counter);
017	  //并对其值加1 
018	  int_counter+=1;
019	  //将加1后的数值再转化成为字符串类型进行存储
020	  String s_counter=Integer.toString(int_counter);
021	  application.setAttribute("counter",s_counter);	  
022   }
023   //如果为空的话,则用setAttribute方法将数值1存储到
024   //application变量名称counter中   
025	else
026	{
027	   application.setAttribute("counter","1");	   
028	}
029	out.println("你是第"+counter+"位访问此的朋友!");
030%>
031</body>
032</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?