List of usage examples for javax.servlet ServletContext getMinorVersion
public int getMinorVersion();
From source file:org.rhq.helpers.rtfilter.util.ServletUtility.java
/** * Get the context root for the specified servlet context. * * @param servletContext/*from www. j a v a 2 s .c o m*/ * * @return */ public static String getContextRoot(ServletContext servletContext) { String ctxName; /* * Get the servlet context. If we have servlet spec >=2.5, then there is a method on the servlet context for it. * Else we need to do some heuristics (which may be wrong at the end). */ int major = servletContext.getMajorVersion(); int minor = servletContext.getMinorVersion(); if (((major == 2) && (minor >= 5)) || (major >= 3)) { ctxName = getContextRootFromSpec25(servletContext); } else { // First we check if the context-root was explicitly given in jboss-web.xml ctxName = getContextRootFromJbossWebXml(servletContext); // Still nothing? try application.xml if (ctxName == null) { ctxName = getContextRootFromApplicationXml(servletContext); } // if all else fails, take the name of the .war if (ctxName == null) { ctxName = getContextRootFromWarFileName(servletContext); } if ((ctxName == null) || "".equals(ctxName)) { ctxName = "__unknown"; } } // Actually the context might always start with / even on Win* so on Unix this is / or /, // but this does not harm if (ctxName.startsWith(SEPARATOR) || ctxName.startsWith("/")) { ctxName = ctxName.substring(1); } return ctxName; }