1. 程式人生 > >JSP——九大隱含物件

JSP——九大隱含物件

1,page----Object

該物件用處甚少

2,config----ServletConfig

String name = config.getInitParameter("name");
Enumeration<String> names = config.getInitParameterNames;
while (names.hasMoreElements()) {
	String key = names.nextElements();
	config.getInitParameter(key);
}

3,out----PrinterWriter

out.prinntln();

4,request-----HttpServletRequest

使用較多

request.setAttribute("name", Object);
request.getAttribute("name");   return Object
Enumeration<String> attNames = request.getAttributeNames();
while (attNames.hasMoreElements()) {
	String attName = attNames.nextElement();
	out.println("<br /> " + attName + " <=> " + request.getAttribute(attName));
}
request.getRemoteAddr();    return addr
request.getQueryString();  return 請求地址?後面的內容
request.getRequestURL();    return   請求的整個地址
request.getRequestURI();    return  請求從相對路徑開始的部分

5,response----HttpServletResponse

response.setContextType(“text/html; charset=utf-8”);

6,session----HttpSession

會話

7,application----ServletContext

8,pagecontext----JSP上下文

9,exception----Exception

錯誤頁面