在servlet中怎么用application?

解决方案 »

  1.   

    request.getSession().getServletContext().getAttribute("mm");
    request.getSession().getServletContext().setAttribute("mm","fdsfas")
      

  2.   

    request.getSession().getServletContext()就是application
      

  3.   

    在servlet类的方法中直接调用getServletContext()就可以获得application
      

  4.   

    在Servlet中类可以直接调用this.getServletContext()这个方法,就能拿到ServletContext.而ServletContext就相当于JSP页面上的application这个对象。