まとめ @ wiki

アプリケーション情報の参照・設定

最終更新:

shells

- view
管理者のみ編集可

アプリケーション情報の参照・設定 【HP


目次


ソース

application.jsp

<%@ page contentType="text/html;charset=Shift_JIS" %>
<%
	String strCnt=(String)(application.getAttribute("cnt"));		// 指定されたアプリケーション情報(属性)を取得
 
	if(strCnt==null){
		strCnt="1";
	}else{
		strCnt=Integer.toString(Integer.parseInt(strCnt)+1);		// String型へ変換
	}
	application.setAttribute("cnt",strCnt);				// 値をセット
									// setAttributeはプリミティブ型を受け取る事ができない
%>
 
<html>
<head>
	<title>簡易アクセスカウンタ(applicationオブジェクト)</title>
</head>
 
<body>
	現在のアクセス数は<%=strCnt%>です。
</body>
</html>

実行結果

現在のアクセス数は○です。

記事メニュー
ウィキ募集バナー