List of usage examples for javax.servlet.http HttpServletRequest getServerPort
public int getServerPort();
From source file:org.apache.struts.util.RequestUtils.java
/** * <p>Return <code>StringBuffer</code> representing the scheme, server, * and port number of the current request. Server-relative URLs can be * created by simply appending the server-relative path (starting with * '/') to this.</p>/*from ww w .j a v a 2 s. co m*/ * * @param request The servlet request we are processing * @return URL representing the scheme, server, and port number of the * current request * @since Struts 1.2.0 */ public static StringBuffer requestToServerStringBuffer(HttpServletRequest request) { return createServerStringBuffer(request.getScheme(), request.getServerName(), request.getServerPort()); }
From source file:com.openkm.util.WebUtils.java
/** * Prepare to send the file./*from ww w . j a v a2 s .com*/ */ public static void prepareSendFile(HttpServletRequest request, HttpServletResponse response, String fileName, String mimeType, boolean inline) throws UnsupportedEncodingException { String userAgent = WebUtils.getHeader(request, "user-agent").toLowerCase(); // Disable browser cache response.setHeader("Expires", "Sat, 6 May 1971 12:00:00 GMT"); response.setHeader("Cache-Control", "must-revalidate"); response.addHeader("Cache-Control", "no-store, no-cache, must-revalidate"); response.addHeader("Cache-Control", "post-check=0, pre-check=0"); response.setHeader("Pragma", "no-cache"); // Set MIME type response.setContentType(mimeType); if (userAgent.contains("msie") || userAgent.contains("trident")) { log.debug("Agent: Explorer ({})", request.getServerPort()); fileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", " "); if (request.getServerPort() == 443) { log.debug("HTTPS detected! Apply IE workaround..."); response.setHeader("Cache-Control", "max-age=1"); response.setHeader("Pragma", "public"); } } else if (userAgent.contains("iphone") || userAgent.contains("ipad")) { log.debug("Agent: iPhone - iPad"); // Do nothing } else if (userAgent.contains("android")) { log.debug("Agent: Android"); fileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", " "); } else if (userAgent.contains("mozilla")) { log.debug("Agent: Mozilla"); fileName = MimeUtility.encodeText(fileName, "UTF-8", "B"); } else { log.debug("Agent: Unknown"); } if (inline) { response.setHeader("Content-disposition", "inline; filename=\"" + fileName + "\""); } else { response.setHeader("Content-disposition", "attachment; filename=\"" + fileName + "\""); } }
From source file:be.fedict.eid.idp.protocol.saml2.AbstractSAML2MetadataHttpServlet.java
private String getLocation(HttpServletRequest request) { String location = "https://" + request.getServerName(); if (request.getServerPort() != 443) { location += ":" + request.getServerPort(); }//from w ww. ja v a 2 s. com location += request.getContextPath() + IdentityProviderProtocolService.PROTOCOL_ENDPOINT_PATH + "/" + getPath(); LOG.debug("location: " + location); return location; }
From source file:org.eclipse.orion.server.servlets.JsonURIUnqualificationStrategy.java
public void run(HttpServletRequest req, Object result) { rewrite(result, req.getScheme(), req.getServerName(), req.getServerPort(), req.getContextPath()); }
From source file:be.fedict.eid.idp.protocol.saml2.artifact.AbstractSAML2ArtifactMetadataHttpServlet.java
@Override public EntityDescriptor getEntityDescriptor(HttpServletRequest request, IdentityProviderConfiguration configuration) { String artifactResolutionLocation = "https://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + IdentityProviderProtocolService.WS_ENDPOINT_CONTEXT_PATH + "/saml2/artifact"; LOG.debug("Artifact resolution location: " + artifactResolutionLocation); EntityDescriptor entityDescriptor = super.getEntityDescriptor(request, configuration); // add ArtifactResolutionService ArtifactResolutionService artifactResolutionService = Saml2Util .buildXMLObject(ArtifactResolutionService.class, ArtifactResolutionService.DEFAULT_ELEMENT_NAME); artifactResolutionService.setLocation(artifactResolutionLocation); artifactResolutionService.setBinding(SAMLConstants.SAML2_SOAP11_BINDING_URI); artifactResolutionService.setIndex(0); artifactResolutionService.setIsDefault(true); IDPSSODescriptor idpssoDescriptor = (IDPSSODescriptor) entityDescriptor.getRoleDescriptors().get(0); idpssoDescriptor.getArtifactResolutionServices().add(artifactResolutionService); return entityDescriptor; }
From source file:cn.vlabs.duckling.api.umt.sso.configable.servlet.LogoutServlet.java
/** * url?contextPath// w ww . j a va 2 s. co m * @param request http * */ private String getRootUrlWithOutContextPath(HttpServletRequest request) { String url = request.getScheme() + "://" + request.getServerName(); int port = request.getServerPort(); if ((port != HTTP_DEFAULT_PORT) && (port != HTTPS_DEFAULT_PORT)) { url = url + ":" + port; } return url; }
From source file:cn.edu.zjnu.acm.judge.user.ResetPasswordController.java
private String getPath(HttpServletRequest request, String... params) { int serverPort = request.getServerPort(); int defaultPort = request.isSecure() ? 443 : 80; StringBuilder sb = new StringBuilder(80); sb.append(request.getScheme()).append("://").append(request.getServerName()); if (serverPort != defaultPort) { sb.append(":").append(serverPort); }//from w ww. j a va 2 s.c om sb.append(request.getContextPath()); for (String param : params) { sb.append(param); } return sb.toString(); }
From source file:org.hoteia.qalingo.core.web.bean.clickstream.ClickstreamRequest.java
public ClickstreamRequest(HttpServletRequest request, Date timestamp) { protocol = request.getProtocol();/*from w w w .j a v a2 s . co m*/ serverName = request.getServerName(); serverPort = request.getServerPort(); requestURI = request.getRequestURI(); queryString = request.getQueryString(); remoteUser = request.getRemoteUser(); this.timestamp = timestamp; }
From source file:com.camel.framework.tag.StaticTag.java
@Override public int doStartTag() throws JspException { this.pageContext.getServletConfig(); // jspJspWriter JspWriter out = this.pageContext.getOut(); // environmentConfig.xml?????value String resourcesUrl = null;// w ww . j ava 2s. co m if (null != ConfigParamMap.getConfigParamMap()) { ConfigParamMap.getValue(IEnvironmentConfigBasic.RESOURCES_URL); } // ?null??URL if (null == resourcesUrl) { HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); resourcesUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); } if (StringUtils.isNotBlank(resourcesUrl)) { try { // ?resourcesUrl????? out.print(resourcesUrl); } catch (IOException e) { logger.error("Could not print out value '" + resourcesUrl, e); } } else { logger.error("resourcesUrl is null,so static tag is invalid"); } return SKIP_BODY; }
From source file:org.cloudifysource.rest.controllers.AdminAPIController.java
private String getRemoteHostAddress(HttpServletRequest httpServletRequest) { String host = httpServletRequest.getServerName(); int port = httpServletRequest.getServerPort(); return "http://" + host + ":" + port; }