当前位置: 技术问答>java相关
请问PageContext和ServletContext有什么区别?
来源: 互联网 发布时间:2015-11-06
本文导语: rt | pageContext跟servletContext的区别是有的,呵呵 你去看看api吧 pageContext是用在jsp中,主要是用到标签类中,PageContext extends JspContext to provide useful context information for when JSP technology is use...
rt
|
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
你去看看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
|
PageContext就是JSP中的page,ServletContext就是JSP中的application。两者的scope不一样。
|
是啊,在jsp里用pageContext,servlet里用servletContext。要用对地方,否则会运行不了的。
|
up!
好!
好!