application 长用到的API

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

<%

    out.print("java servlet API Version is :" + application.getMajorVersion() + "." + application.getMinorVersion() + "<br>");
   
    out.print("URL of 'application.jsp' is " + application.getResource("/application.jsp") + "<br>");
    
    out.print("getServerInfo():" + application.getServerInfo() + "<br>");
    
    out.println(application.getRealPath(""));
%>
</body>
</html>

 

返回结果如下:

java servlet API Version is :2,5
URL of 'application.jsp' is jndi:/localhost/servlet001/application.jsp
getServerInfo():Apache Tomcat/6.0.14
D:\webTest\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\servlet001


其中jndi是sun公司规定的协议

 

posted on 2014-05-23 11:18  端着咖啡码农  阅读(233)  评论(0编辑  收藏  举报