servlet的application物件的使用

2021-09-07 09:46:21 字數 1085 閱讀 8251

(5) servletcontext類:用於表示應用程式的上下文。

乙個servletcontext類的物件表示乙個web應用程式的上下文。

具體來說:在web伺服器中,提供了乙個web應用程式的執行時環境,專門負責web應用程式的部署、編譯、執行以及生命週期的管理,通過servletcontext類,可以獲取web應用程式的執行時環境資訊。

常識:jsp引擎、servlet引擎、jsp容器和servlet容器,都是指web伺服器,web伺服器用於管理所有web應用程式。

方法名描述

string getattribute(string name)

根據屬性名稱獲取屬性值。

enumeration getattributenames()

獲取所有的屬性名稱。

void setattribute(string name, object object)

設定屬性,指定屬性名稱和屬性值。

void removeattribute(string name)

根據屬性名稱刪除對應的屬性。

servletcontext getcontext(string uripath)

獲取指定url的servletcontext物件。

string getcontextpath()

獲取當前web應用程式的根目錄。

string getinitparameter(string name)

根據初始化引數名稱,獲取初始化引數值。

int getmajorversion()

獲取servlet api的主版本號。

int getminorversion()

獲取servlet api的次版本號。

string getmimetype(string file)

獲取指定檔案的mime 型別。

string getservletinfo()

獲取當前web伺服器的版本資訊。

string getservletcontextname()

獲取當前web應用程式的名稱。

void log(string message)

將資訊寫入日誌檔案中。

Android專案工具類之Application

private 得到代表我們的應用程式的類,使用它可以獲得當前應用的主題和資源檔案以及最常用的上下文 private static int maintid 得到主線程pid private static handler handler 得到ui執行緒handler,用來進行handler訊息或者執行...

Servlet學習 servlet的生命週期

servlet介面中定義了作為乙個servlet在整個生命週期中應該擁有三個階段 1,初始化 2,服務 3,銷毀 servlet的生命週期是由容器管理的 servlet的生命週期 簡化版 適用於筆試的時候 1,servlet的生命週期是由容器管理的 這句話非常重要 2.他分別經歷三個階段 初始化 服...

Servlet入門 servlet路徑問題

1.servlet路徑 url pattern 作用 將乙個請求網路位址和servlet類建立乙個對映關係 servlet可以對映多個url 例如 myservlet com.test.myservlet myservlet mmmyservlet kk2.url對映模式 配置 url位址取值可以是...