1. 程式人生 > >Jsp中9大內建物件

Jsp中9大內建物件

頻繁使用的:

            request:(HttpServletRequest):getAttribute("key"),setAttribute("key",value);getParameter("name")

            session:(HttpSession):setAttribute("key",value),getAttribute("key"),removeAttribute("key");

            pageContext:(PageContext):getRequest(),getResponse(),getSession(),getServletContext();

經常使用的:

            response:(HttpServletResponse):addCookies(),setContentType(),sendRedirect("url");


            application:(ServletContext):setAttribute("key",value),getAttribute("key"),removeAttribute("key")

            out:(JspWriter):print(),write(),writeln(),close(),flush();

其他:     

            page:(Obiect):

            config:(ServletContext):頁面配置物件

            exception:(Throwable):異常處理物件(僅當jsp頁面isErrorPage="true"時存在);


兩種跳轉方式:

       請求轉發跳轉:request.getRequestDispatcher(url).forword(request,response);

       重定向跳轉:response.sendRedirect(url);