List of usage examples for javax.servlet.http HttpServletRequest getServerPort
public int getServerPort();
From source file:org.apache.wookie.WidgetWebMenuServlet.java
/** * Get a connector service for the first test user. * * @param request//from w w w. j ava 2s .c o m * @return * @throws WookieConnectorException */ private AbstractWookieConnectorService getConnectorService(HttpServletRequest request) throws WookieConnectorException { if (connectorService == null) { StringBuilder sbUrl = new StringBuilder(request.getScheme()); sbUrl.append("://"); sbUrl.append(request.getServerName()); sbUrl.append(":"); sbUrl.append(request.getServerPort()); sbUrl.append(request.getContextPath()); connectorService = new WookieConnectorService(sbUrl.toString(), "TEST", "myshareddata"); } return connectorService; }
From source file:edu.usc.lunchnlearn.elasticsearch.interceptor.BreadCrumbInterceptor.java
private Crumb createIndexCrumb(Crumb firstCrumb, HttpServletRequest request) { Crumb indexCrumb = new Crumb(); StringBuffer sb = new StringBuffer(); if (request.getScheme().equals("http") && request.getHeader("x-forwarded-proto") != null) { sb.append("https://"); } else {/*from ww w .j a v a 2 s .com*/ sb.append(request.getScheme()).append("://"); } sb.append(request.getServerName()); if (request.getServerPort() != 80 && request.getServerPort() != 443) { sb.append(":").append(request.getServerPort()); } sb.append(request.getContextPath()); sb.append(request.getServletPath()); sb.append("/index.html"); indexCrumb.setUrl(sb.toString()); indexCrumb.setDisplayText("Index"); indexCrumb.setX(firstCrumb.getX() - 100L); return indexCrumb; }
From source file:org.cloudfoundry.identity.uaa.varz.VarzEndpoint.java
/** * Compute a base url for links./*from w w w. j a v a2 s . co m*/ * * @param request the current request * @return a computed base url for this application, or the hard-coded {@link #setBaseUrl(String) value} if set */ @ModelAttribute("baseUrl") public String getBaseUrl(HttpServletRequest request) { if (this.baseUrl != null) { return this.baseUrl; } String scheme = request.getScheme(); StringBuffer url = new StringBuffer(scheme + "://"); url.append(request.getServerName()); int port = request.getServerPort(); if ((scheme.equals("http") && port != 80) || (scheme.equals("https") && port != 443)) { url.append(":" + port); } url.append(request.getContextPath()); return url.toString(); }
From source file:com.fluidops.iwb.api.RequestMapperImpl.java
private String hostUrl(HttpServletRequest request) { return String.format("%s://%s:%s", request.getScheme(), request.getServerName(), request.getServerPort()); }
From source file:eionet.cr.web.action.SpatialSearchActionBean.java
/** * @return the contextUrl//from w w w. j av a 2 s. c om */ public String getContextUrl() { if (contextUrl == null) { HttpServletRequest request = getContext().getRequest(); StringBuffer buf = new StringBuffer(request.getScheme()).append("://").append(request.getServerName()); int port = request.getServerPort(); if (port > 0 && !(port == 80 && request.getScheme().equalsIgnoreCase("http"))) { buf.append(":").append(port); } String contextPath = request.getContextPath(); if (contextPath != null) { buf.append(contextPath.trim()); } contextUrl = buf.toString(); } return contextUrl; }
From source file:org.apache.axis.transport.http.AxisServletBase.java
/** * extract the base of our webapp from an inbound request * * @param request request containing http://foobar/axis/services/something * @return some URL like http://foobar:8080/axis/ *///from w w w . j a v a 2s . co m protected String getWebappBase(HttpServletRequest request) { StringBuffer baseURL = new StringBuffer(128); baseURL.append(request.getScheme()); baseURL.append("://"); baseURL.append(request.getServerName()); if (request.getServerPort() != 80) { baseURL.append(":"); baseURL.append(request.getServerPort()); } baseURL.append(request.getContextPath()); return baseURL.toString(); }
From source file:svnserver.ext.web.server.WebServer.java
@NotNull public URI getUrl(@NotNull HttpServletRequest req) { if (config.getBaseUrl() != null) { return URI.create(config.getBaseUrl()).resolve(req.getRequestURI()); }// w ww.j av a 2s.c o m String host = req.getHeader(HttpHeaders.HOST); if (host == null) { host = req.getServerName() + ":" + req.getServerPort(); } return URI.create(req.getScheme() + "://" + host + req.getRequestURI()); }
From source file:org.cloudfoundry.identity.uaa.security.web.CorsFilter.java
public String getRequestInfo(HttpServletRequest request) { return String.format("URI: %s; Scheme: %s; Host: %s; Port: %s; Origin: %s; Method: %s", request.getRequestURI(), request.getScheme(), request.getServerName(), request.getServerPort(), request.getHeader("Origin"), request.getMethod()); }
From source file:com.searchbox.framework.web.Auth0LoginController.java
@RequestMapping("/index") protected String login(final Map<String, Object> model, final HttpServletRequest req) { logger.info("Performing login"); detectError(model);/* w w w. j a v a 2 s . c om*/ // add a Nonce value to session storage NonceUtils.addNonceToStorage(req); model.put("clientId", appConfig.getClientId()); model.put("clientDomain", appConfig.getDomain()); model.put("loginCallback", appConfig.getLoginCallback()); model.put("state", SessionUtils.getState(req)); int port = req.getServerPort(); String url; if (port == 80) { url = String.format("%s://%s/", req.getScheme(), req.getServerName()); } else { url = String.format("%s://%s:%d/", req.getScheme(), req.getServerName(), req.getServerPort()); } String redirectUrl = appConfig.getIssuer() + "authorize?" + "response_type=code&scope=openid%20profile&" + "client_id=" + appConfig.getClientId() + "&" + "state=" + SessionUtils.getState(req) + "&redirect_uri=" + url + "callback"; return "redirect:" + redirectUrl; }
From source file:net.cloudfree.apps.shop.internal.app.ListingServlet.java
private StringBuilder getBaseUrl(final HttpServletRequest req) { final StringBuilder builder = new StringBuilder(50); builder.append(req.getScheme());//from w w w .j a va2 s . c o m builder.append("://"); builder.append(req.getServerName()); if ((req.getScheme().equals("http") && (req.getServerPort() != 80)) || (req.getScheme().equals("https") && (req.getServerPort() != 443))) { builder.append(":"); builder.append(req.getServerPort()); } builder.append(req.getContextPath()); builder.append(req.getServletPath()); builder.append("/"); return builder; }