取得内置对象
PageContext对象不能再Servlet中取得,它属于JSP页面
取得session对象(通过HttpServletRequest接口)
public HttpSession getSession()
取得application对象
GenericServlet类中的方法
public ServletContext getServletContext()
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
ServletContext app = super.getServletContext();
System.out.println(app.getRealPath("/")+"*******");
}
HttpSession接口对象取得依靠的是HttpServletRequest(http协议)
ServletContext接口对象取得依靠的是GenericServlet(不受协议控制)