@634

JSP

Advertisement

applicationオブジェクト

javax.servlet.ServletContext のオブジェクト。

applicationオブジェクトの利用

<%@ page contentType="text/html; charset=Shift_JIS" %>
<meta http-equiv="Content-Type" content="text/html;charset=Shift_JIS">
<html lang="ja">
<head><title>テスト</title>
</head>
<body>

<%-- コンテナの表示 --%>
<%= application.getServerInfo() %><br>

<%-- 指定ファイルのMIMEタイプの取得 --%>
<%= application.getMimeType("./test.html") %>

</body>
</html>
実行結果(例)
Apache Tomcat/4.1.27
text/html

例2 - ログファイルへの書き込み

<%@ page contentType="text/html; charset=Shift_JIS" %>
<meta http-equiv="Content-Type" content="text/html;charset=Shift_JIS">
<html lang="ja">
<head><title>テスト</title>
</head>
<body>

<%
    application.log("ログ出力のテスト");
    application.log(request.getRequestURL().toString());
%>

</body>
</html>
実行結果(ログファイル)
2003-09-26 20:30:11 SessionListener: sessionCreated('403AB8AF1EB136209D41256C0626E378')
2003-09-26 20:30:11 ログ出力のテスト
2003-09-26 20:30:11 http://localhost:8080/sample/application.jsp

Advertisement

ショートカット

634
634ブログ
このカテゴリのトップページに戻る
Incubator(Pukiwiki)
634ラボ
   UIコレクションギャラリー
   ZO-3ジェネレーター

サイト検索


Y!ログール