jsp application内置对象深入理解与应用

// javax.servlet.jsp.PageContext:

public abstract ServletContext getServletContext();// application = pageContext.getServletContext();

// web容器实现了此抽象方法! 凡是接口或类中的抽象方法直接使用,都是因为或JVM内部实现了抽象!
// 此方法表示获取当前页面会话的应用程序对象,也就是application,通过他可以设置和获取的属性!
    The ServletContext instance.
// javax.servlet.ServeletContext:

public interface ServletContext;// 每个servletContext对象代表一个应用程序,application是一个对象!

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.
There is one context per “web application” per Java Virtual Machine. (A “web application” is a collection of servlets and content installed under a specific subset of the server's URL namespace such as /catalog and possibly installed via a .war file.)
// 方法:

ServletContext getContext(String uripath);// 获取指定定位目录的上下文对象,

Returns a ServletContext object that corresponds to a specifi

String getRealPath(String path);// 获取目录的真实路径

Returns a String containing the real path for a given virtual path. For example, the path “/index.html” returns the absolute file path on the server's filesystem would be served by a request for “https://host/contextPath/index.html”, where contextPath is the context path of this ServletContext..
—获取目录的在上的真实目录

// 以上代码等价于以下代码:

————application内置对象:
// javax.servlet.jsp.PageContext:

public abstract ServletContext getServletContext();// application = pageContext.getServletContext();

// web容器实现了此抽象方法! 凡是接口或类中的抽象方法直接使用,都是因为或JVM内部实现了抽象!
// 此方法表示获取当前页面会话的服务器应用程序对象,也就是application,通过他可以设置和获取服务器的属性!
    The ServletContext instance.
// javax.servlet.ServeletContext:

public interface ServletContext;// 每个servletContext对象代表一个服务器应用程序,application是一个对象!

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.
There is one context per “web application” per Java Virtual Machine. (A “web application” is a collection of servlets and content installed under a specific subset of the server's URL namespace such as /catalog and possibly installed via a .war file.)
// 方法:

ServletContext getContext(String uripath);// 获取指定定位目录的服务器上下文对象,

Returns a ServletContext object that corresponds to a specifi

String getRealPath(String path);// 获取目录的真实路径

Returns a String containing the real path for a given virtual path. For example, the path “/index.html” returns the absolute file path on the server's filesystem would be served by a request for “https://host/contextPath/index.html”, where contextPath is the context path of this ServletContext..
—获取虚拟目录的在服务器上的真实目录

// 以上代码等价于以下代码:

声明: 除非转自他站(如有侵权,请联系处理)外,本文采用 BY-NC-SA 协议进行授权 | 智乐兔
转载请注明:转自《jsp application内置对象深入理解与应用
本文地址:https://www.zhiletu.com/archives-192.html
关注公众号:智乐兔

赞赏

wechat pay微信赞赏alipay pay支付宝赞赏

上一篇
下一篇

相关文章

在线留言

你必须 登录后 才能留言!

在线客服
在线客服 X

售前: 点击这里给我发消息
售后: 点击这里给我发消息

智乐兔官微