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公司规定的协议
珍惜现在,珍惜每一分,每一秒。
从不放弃,坚持。。。。。