两个对象都有setAttribute和getAttribute,请问用法一样吗?

解决方案 »

  1.   

    PageContext就是JSP中的page,ServletContext就是JSP中的application。两者的scope不一样。
      

  2.   

    是啊,在jsp里用pageContext,servlet里用servletContext。要用对地方,否则会运行不了的。
      

  3.   

    为什么在标记库中有时用pageContext有时用servletContext。
      
      

  4.   

    pageContext跟servletContext的区别是有的,呵呵
    你去看看api吧pageContext是用在jsp中,主要是用到标签类中,PageContext extends JspContext to provide useful context information for when JSP technology is used in a Servlet environment而ServletContext则是servlet中使用,它只是一个接口。Defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file。
    The ServletContext object is contained within the ServletConfig object, which the Web server provides the servlet when the servlet is initialized