List of usage examples for javax.servlet.http HttpServletRequest getScheme
public String getScheme();
From source file:nl.b3p.gis.utils.CrossWebAppUtil.java
private static String getServerURL(HttpServletRequest request) { return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort(); }
From source file:com.opendesign.utils.ControllerUtil.java
public static String getHostName(HttpServletRequest request) { String scheme = request.getScheme(); String serverName = request.getServerName(); int portNumber = request.getServerPort(); String contextPath = request.getContextPath(); String host = scheme + "://" + serverName + contextPath + ":" + portNumber; if (portNumber == 80) { host = scheme + "://" + serverName + contextPath; }/*from ww w. j a va2 s . c o m*/ return host; }
From source file:com.flowlogix.util.PathUtil.java
/** * @param request/*www. j ava 2 s .c om*/ * @return complete server path i.e. https://www.glowlogix.com:8080 */ public static String getServerPath(HttpServletRequest request) { String port = ""; switch (request.getScheme()) { case "http": if (request.getServerPort() != 80) { port = ":" + Integer.toString(request.getServerPort()); } break; case "https": if (request.getServerPort() != 443) { port = ":" + Integer.toString(request.getServerPort()); } break; } return String.format("%s://%s%s", request.getScheme(), request.getServerName(), port); }
From source file:com.vmware.demo.ListController.java
public static String getURLWithContextPath(HttpServletRequest request) { return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/sso"; }
From source file:com.manydesigns.elements.servlet.ServletUtils.java
public static String getApplicationBaseUrl(HttpServletRequest req) { String scheme = req.getScheme(); int port = req.getServerPort(); String portString;/*from w w w .j a v a 2 s . c o m*/ if ((scheme.equals("http") && port == 80) || (scheme.equals("https") && port == 443)) { portString = ""; } else { portString = ":" + port; } return scheme + "://" + req.getServerName() + portString + req.getContextPath(); }
From source file:info.magnolia.cms.util.RequestDispatchUtil.java
private static boolean isUsingStandardPort(HttpServletRequest request) { String requestScheme = request.getScheme(); int serverPort = request.getServerPort(); return (serverPort == 80 && "http".equals(requestScheme)) || (serverPort == 443 && "https".equals(requestScheme)); }
From source file:ServletUtils.java
/** * NOT UNIT TESTED Returns the base url (e.g, <tt>http://myhost:8080/myapp</tt>) suitable for * using in a base tag or building reliable urls. *///from w w w .j a v a 2s .co m public static String getBaseUrl(HttpServletRequest request) { if ((request.getServerPort() == 80) || (request.getServerPort() == 443)) return request.getScheme() + "://" + request.getServerName() + request.getContextPath(); else return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); }
From source file:org.sventon.util.WebUtils.java
/** * Extracts the full request URL, including scheme, server name, * server port (if not 80) and context path. * * @param request The request./*from w w w. j a v a 2 s . c o m*/ * @return The full URL, ending with a forward slash (/). */ public static String extractBaseURLFromRequest(final HttpServletRequest request) { final StringBuilder sb = new StringBuilder(); sb.append(request.getScheme()); sb.append("://"); sb.append(request.getServerName()); if (request.getServerPort() != 80) { sb.append(":"); sb.append(request.getServerPort()); } sb.append(request.getContextPath()); sb.append("/"); return sb.toString(); }
From source file:org.mytms.common.web.util.RequestUtil.java
/** * Convenience method to obtain the server prefix of the current request. * Useful for many modules that configure Relative URL's and need to send absolute URL's * to Third Party Gateways.// w ww. ja va2 s .com */ public static String getRequestedServerPrefix() { HttpServletRequest request = RequestContext.getBroadleafRequestContext().getRequest(); String scheme = request.getScheme(); StringBuilder serverPrefix = new StringBuilder(scheme); serverPrefix.append("://"); serverPrefix.append(request.getServerName()); if ((scheme.equalsIgnoreCase("http") && request.getServerPort() != 80) || (scheme.equalsIgnoreCase("https") && request.getServerPort() != 443)) { serverPrefix.append(":"); serverPrefix.append(request.getServerPort()); } return serverPrefix.toString(); }
From source file:no.kantega.commons.util.URLHelper.java
/** * @param request - current request/* w ww. j av a 2 s. c o m*/ * @return scheme, servername and port. If port is 80 or 443 it is omitted. */ public static String getServerURL(HttpServletRequest request) { int port = request.getServerPort(); String portStr = isNormalPort(port) ? "" : ":" + port; return request.getScheme() + "://" + request.getServerName() + portStr; }