方法
|
說明
|
Object getAttribute(String name)
|
返回name所指定的屬性值 |
void setAttribute(String name, Object obj)
|
設定name所指定的屬性值爲obj |
void removeAttribute(String name)
|
刪除name所指定的屬性
|
java.util.Enumeration getAttributeNames()
|
返回request對象所有屬性的名稱集合
|
String getPerameter(String name)
|
從客戶端獲取name所指定的參數值
|
java.util.Enumeration getParameterNames()
|
從客戶端獲取所有參數名稱
|
String[] getPerameterValues(String name)
|
從客戶端獲取name所指定參數的所有值
|
int getServerPort()
|
返回服務器接受請求的端口 |
String getServerName()
|
返回服務器名稱
|
String getRemoteAddr()
|
獲取客戶端的IP地址
|
int getRemotePort() |
獲取服務器請求端口
|
String getContextPath()
|
返回環境路徑(Web服務程序根目錄)
|
String getCharacterEncoding()
|
返回請求正文中所使用的字符編碼
|
void setCharacterEncoding(String chean)
|
設定請求正文中所使用的字符編碼
|
Cookis[] getCookies() |
返回客戶端所有的Cookie對象
|
Session getSession()
|
返回請求相關的session對象
|
String getContentType()
|
返回請求正文的MIME類型
|
int getContentLength()
|
返回請求的Body的長度,單位爲字節
|
方法
|
說明
|
void sendRedirect(String redirectURL)
|
將客戶端重定向到指定的URL
|
void setContentType(String contentType)
|
設置響應數據內容的類型
|
void setContentLength(int contentLength)
|
設置響應數據內容的長度 |
void setHeader(String name, String value)
|
設置HTTP應答報文的首部字段和值及頁面的自動刷新
|
void setStatus(int n)
|
設置響應的狀態行
|
ServletOutputStream getoutputStream()
|
獲取二進制類型的輸出流對象
|
PrintWriter getWriter()
|
獲取字符類型的輸出流對象
|
String encodeRedirectURL(String url) |
編碼指定的URL
|
String encodeRedirectURL(String url)
|
編碼指定的URL,以便向sendRedirect發送
|
int getBufferSize()
|
獲取緩衝區大小
|
void setBufferSize(int bufferSize) | 設置緩衝區大小 |
void flushBuffer()
|
強制發送當前緩衝區的內容到緩衝區
|
void resetBuffer()
|
清除響應緩衝區中的內容
|
void addCookie(Cookie cookie)
|
向客戶端發送一個Cookie
|
void addHeader(String name, String value)
|
添加HTTP文件的頭文件
|
boolean isCommitted()
|
判斷服務器是否已將數據輸出客戶端
|
session.setAttribute("level", new Integer(3)); 設置整數
方法
|
說明
|
getCreationTime()
|
返回session建立的時間,返回值爲從格林威治時間1970.1.1開始算起到session建立時的毫秒數
|
getlastAccessedTime() |
返回客戶端對服務器端提出請求至處理session中數據最後的時間,若爲新建立的session則返回-1
|
getMaxInactiveInterval()
|
返回客戶端未對session提出請求而session開始停滯到自動消失之間所間隔的時間返回值以毫秒爲單位
|
intNew()
|
返回布爾值表示是否爲新建的session
|
SetMaxInactiveInterval(int interval) |
設置客戶端未對session提出請求而session開始停滯到自動消失之間所間隔的時間爲interval,以秒爲單位
|
方法
|
說明
|
getMajorVersion()
|
返回服務器解釋引擎所支持的最新Servlet API版本
|
getMinorVersion()
|
返回服務器解釋引擎所支持的最低Servlet API版本
|
getMinmeType(String file)
|
返回文件file的文件格式與編碼方式
|
getRealPath(String path)
|
返回虛擬路徑path的真是路徑
|
getServerInfo()
|
返回服務器解釋引擎的信息
|
方法
|
說明
|
Object getAttribute(String name)
|
返回當前頁面內的name變量
|
void setAttribute(String name, Object obj)
|
設定當前頁面內name變量爲obj
|
void removeAttribute(String name)
|
刪除當前頁面的name變量
|
HttpSession getSession()
|
取得頁面的session對象
|
ServletContext getServletContext()
|
返回ServletContext對象這個對象對所有的頁面都是共享的
|
javax.servlet.ServletRequest getRequest()
|
該方法的返回對象時JSP內置對象request,主要用於獲取客戶端的信息
|
方法
|
說明
|
String getInitParameter(String name)
|
返回所指定的初始參數
|
java.util.Enumeration getInitParameterNames()
|
返回所有初始化參數
|
ServletContext getServletContext()
|
返回Servlet相關的上下文對象
|
String getServletName()
|
返回Servlet名稱
|
方法
|
說明
|
String getMessage()
|
返回錯誤信息
|
String getLocalizedMessage()
|
取得本地語系的錯誤提示信息
|
void printStackTrace()
|
以標準錯誤的形式輸出一個錯誤和錯誤的堆棧
|
String toString()
|
該方法以字符串形式返回一個對異常的描述 |
Throwable fillInStackTrace()
|
重寫錯誤的堆棧
|