本文整理汇总了Java中javax.servlet.ServletContext.getServerInfo方法的典型用法代码示例。如果您正苦于以下问题:Java ServletContext.getServerInfo方法的具体用法?Java ServletContext.getServerInfo怎么用?Java ServletContext.getServerInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.ServletContext
的用法示例。
在下文中一共展示了ServletContext.getServerInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: VersionModel
import javax.servlet.ServletContext; //导入方法依赖的package包/类
/**
* Constructor
* @param context the servlet context
*/
public VersionModel(ServletContext context) {
restVersion = RESTServlet.VERSION_STRING;
jvmVersion = System.getProperty("java.vm.vendor") + ' ' +
System.getProperty("java.version") + '-' +
System.getProperty("java.vm.version");
osVersion = System.getProperty("os.name") + ' ' +
System.getProperty("os.version") + ' ' +
System.getProperty("os.arch");
serverVersion = context.getServerInfo();
jerseyVersion = ServletContainer.class.getPackage()
.getImplementationVersion();
}
示例2: getCGIVariable
import javax.servlet.ServletContext; //导入方法依赖的package包/类
protected String getCGIVariable( String name ) {
String retVal = null;
if ( name.equalsIgnoreCase( "AUTH_TYPE" ) ) {
retVal = req.getAuthType();
} else if ( name.equalsIgnoreCase( "CONTENT_LENGTH" ) ) {
int contentLength = req.getContentLength();
if ( contentLength >= 0 ) {
retVal = Integer.toString( contentLength );
}
} else if ( name.equalsIgnoreCase( "CONTENT_TYPE" ) ) {
retVal = req.getContentType();
} else if ( name.equalsIgnoreCase( "DOCUMENT_NAME" ) ) {
String requestURI = req.getRequestURI();
retVal = requestURI.substring( requestURI.lastIndexOf('/') + 1 );
} else if ( name.equalsIgnoreCase( "DOCUMENT_URI" ) ) {
retVal = req.getRequestURI();
} else if ( name.equalsIgnoreCase( "GATEWAY_INTERFACE" ) ) {
retVal = "CGI/1.1";
} else if ( name.equalsIgnoreCase( "PATH_INFO" ) ) {
retVal = req.getPathInfo();
} else if ( name.equalsIgnoreCase( "PATH_TRANSLATED" ) ) {
retVal = req.getPathTranslated();
} else if ( name.equalsIgnoreCase( "QUERY_STRING" ) ) {
//apache displays this as an empty string rather than (none)
retVal = nullToEmptyString( req.getQueryString() );
} else if ( name.equalsIgnoreCase( "QUERY_STRING_UNESCAPED" ) ) {
String queryString = req.getQueryString();
if ( queryString != null ) {
retVal = URLDecoder.decode( queryString );
}
} else if ( name.equalsIgnoreCase( "REMOTE_ADDR" ) ) {
retVal = req.getRemoteAddr();
} else if ( name.equalsIgnoreCase( "REMOTE_HOST" ) ) {
retVal = req.getRemoteHost();
} else if ( name.equalsIgnoreCase( "REMOTE_USER" ) ) {
retVal = req.getRemoteUser();
} else if ( name.equalsIgnoreCase( "REQUEST_METHOD" ) ) {
retVal = req.getMethod();
} else if ( name.equalsIgnoreCase( "SCRIPT_NAME" ) ) {
retVal = req.getServletPath();
} else if ( name.equalsIgnoreCase( "SERVER_NAME" ) ) {
retVal = req.getServerName();
} else if ( name.equalsIgnoreCase( "SERVER_PORT" ) ) {
retVal = Integer.toString( req.getServerPort() );
} else if ( name.equalsIgnoreCase( "SERVER_PROTOCOL" ) ) {
retVal = req.getProtocol();
} else if ( name.equalsIgnoreCase( "SERVER_SOFTWARE" ) ) {
ServletContext servletContext = servlet.getServletContext();
retVal = servletContext.getServerInfo();
}
return retVal;
}