List of usage examples for javax.servlet.http HttpServletRequest getScheme
public String getScheme();
From source file:it.greenvulcano.gvesb.adapter.http.utils.DumpUtils.java
public static void dump(HttpServletRequest request, StringBuffer log) throws IOException { String hN;/*from w w w .j a va 2s .co m*/ log.append("-- DUMP HttpServletRequest START").append("\n"); log.append("Method : ").append(request.getMethod()).append("\n"); log.append("RequestedSessionId : ").append(request.getRequestedSessionId()).append("\n"); log.append("Scheme : ").append(request.getScheme()).append("\n"); log.append("IsSecure : ").append(request.isSecure()).append("\n"); log.append("Protocol : ").append(request.getProtocol()).append("\n"); log.append("ContextPath : ").append(request.getContextPath()).append("\n"); log.append("PathInfo : ").append(request.getPathInfo()).append("\n"); log.append("QueryString : ").append(request.getQueryString()).append("\n"); log.append("RequestURI : ").append(request.getRequestURI()).append("\n"); log.append("RequestURL : ").append(request.getRequestURL()).append("\n"); log.append("ContentType : ").append(request.getContentType()).append("\n"); log.append("ContentLength : ").append(request.getContentLength()).append("\n"); log.append("CharacterEncoding : ").append(request.getCharacterEncoding()).append("\n"); log.append("---- Headers START\n"); Enumeration<String> headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { hN = headerNames.nextElement(); log.append("[" + hN + "]="); Enumeration<String> headers = request.getHeaders(hN); while (headers.hasMoreElements()) { log.append("[" + headers.nextElement() + "]"); } log.append("\n"); } log.append("---- Headers END\n"); log.append("---- Body START\n"); log.append(IOUtils.toString(request.getInputStream())).append("\n"); log.append("---- Body END\n"); log.append("-- DUMP HttpServletRequest END \n"); }
From source file:net.naijatek.myalumni.util.utilities.ParamUtil.java
public static String getServer2(final HttpServletRequest request) { StringBuffer server = new StringBuffer(128); server.append(request.getScheme()); server.append("://"); server.append(request.getHeader("host")); return server.toString(); }
From source file:org.geoserver.ows.util.ResponseUtils.java
/** * Pulls out the base url ( from the client point of view ), from the given request object. * // w w w. j a v a2 s . co m * @return A String of the form "<scheme>://<server>:<port>/<context>/" */ public static String baseURL(HttpServletRequest req) { StringBuffer sb = new StringBuffer(req.getScheme()); sb.append("://").append(req.getServerName()).append(":").append(req.getServerPort()) .append(req.getContextPath()).append("/"); return sb.toString(); }
From source file:net.naijatek.myalumni.util.utilities.ParamUtil.java
public static String getServer(final HttpServletRequest request) { StringBuffer server = new StringBuffer(128); String scheme = request.getScheme(); int port = request.getServerPort(); if (port < 0) { port = 80; // Work around java.net.URL bug }/* w ww .ja va2s. c o m*/ server.append(scheme); server.append("://"); server.append(request.getServerName()); if (scheme.equals("http") && port != 80 || scheme.equals("https") && port != 443) { server.append(':'); server.append(port); } return server.toString(); }
From source file:org.jspresso.framework.util.resources.server.ResourceProviderServlet.java
/** * Computes the url where the resource can be uploaded. * * @param request/*from www. j av a 2s. c o m*/ * the incoming HTTP request. * @return the resource url. */ private static String computeUploadUrl(HttpServletRequest request) { String baseUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + UPLOAD_SERVLET_URL_PATTERN; return baseUrl; }
From source file:org.jspresso.framework.util.resources.server.ResourceProviderServlet.java
/** * Computes a static URL based on servlet request. * * @param request// w ww . j a v a 2 s.c om * the servlet request. * @param relativePath * the relative path. * @return the absolute static URL. */ private static String computeStaticUrl(HttpServletRequest request, String relativePath) { return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/" + relativePath; }
From source file:org.jspresso.framework.util.resources.server.ResourceProviderServlet.java
private static String computeUrl(HttpServletRequest request, String getParameters) { String baseUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + DOWNLOAD_SERVLET_URL_PATTERN; return baseUrl + getParameters; }
From source file:net.ymate.framework.core.util.WebUtils.java
/** * @param request HttpServletRequest/*w w w . jav a2 s. c o m*/ * @return ??URL */ public static String baseURL(HttpServletRequest request) { StringBuilder basePath = new StringBuilder(request.getScheme()).append("://") .append(__doGetSafeServerName(request)); if (request.getServerPort() != 80 && request.getServerPort() != 443) { basePath.append(":").append(request.getServerPort()); } if (StringUtils.isNotBlank(request.getContextPath())) { basePath.append(request.getContextPath()); } if (!basePath.toString().endsWith("/")) { basePath.append("/"); } return basePath.toString(); }
From source file:org.easyrec.util.core.Web.java
/** * returns the complete path of the webapp e.g. * http://my.server.com/easyrec-web///from ww w. ja va 2s .c om * * @param request HttpServletRequest * @return String */ public static String getExtendedWebappPath(HttpServletRequest request) { if (path == null) { String localName = request.getLocalName(); localName = localName.equals("0.0.0.0") ? "localhost" : localName; path = request.getScheme() + "://" + //request.getLocalAddr()+ ":" + localName + ":" + request.getLocalPort() + request.getContextPath(); } return path; }
From source file:org.jamwiki.utils.Utilities.java
/** * Given a request, determine the server URL. * * @return A Server URL of the form http://www.example.com/ *///from w ww.j a v a2 s . c o m public static String getServerUrl(HttpServletRequest request) { return request.getScheme() + "://" + request.getServerName() + ((request.getServerPort() != 80) ? ":" + request.getServerPort() : ""); }