List of usage examples for javax.servlet.http HttpServletRequest getServerName
public String getServerName();
From source file:org.n52.tamis.rest.forward.processes.jobs.StatusRequestForwarder.java
private String constructTamisBaseUrl(HttpServletRequest request) { String target_baseUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); return target_baseUrl; }
From source file:org.stockwatcher.web.rss.BaseRssView.java
protected String getStockLink(HttpServletRequest request, String symbol) { StringBuilder link = new StringBuilder(request.getScheme()); link.append("://"); link.append(request.getServerName()); link.append(":"); link.append(request.getServerPort()); link.append(request.getContextPath()); link.append("/main/stocks/"); link.append(symbol);/*from ww w .j a v a 2 s .c o m*/ return link.toString(); }
From source file:com.dotmarketing.portlets.contentlet.business.FileAssetTest.java
@Before public void before() throws Exception { LicenseTestUtil.getLicense();/*from w w w. j ava 2s .co m*/ client = RestClientBuilder.newClient(); HttpServletRequest request = ServletTestRunner.localRequest.get(); String serverName = request.getServerName(); long serverPort = request.getServerPort(); webTarget = client.target("http://" + serverName + ":" + serverPort + "/"); }
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;/*from w w w . j a v a2 s. com*/ 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:com.tbodt.jswerve.servlet.JSwerveServlet.java
private URI extractUri(HttpServletRequest req) throws ServletException { try {/*from w w w . ja va 2 s .com*/ return new URI(req.getScheme(), UrlUtils.decode(req.getServerName()), UrlUtils.decode(req.getRequestURI()), UrlUtils.decode(req.getQueryString()), null); } catch (URISyntaxException ex) { throw new ServletException("Damn! URI syntax!", ex); } }
From source file:org.opendatakit.dwc.server.GreetingServiceImpl.java
public static String getServerURL(HttpServletRequest req, String relativeServletPath, boolean preserveQS) { // for now, only store the servlet context and the serverUrl String path = req.getContextPath(); Integer identifiedPort = req.getServerPort(); String identifiedHostname = req.getServerName(); if (identifiedHostname == null || identifiedHostname.length() == 0 || identifiedHostname.equals("0.0.0.0")) { try {/*from www . j a v a 2 s . co m*/ identifiedHostname = InetAddress.getLocalHost().getCanonicalHostName(); } catch (UnknownHostException e) { identifiedHostname = "127.0.0.1"; } } String identifiedScheme = "http"; if (identifiedPort == null || identifiedPort == 0) { if (req.getScheme().equals(identifiedScheme)) { identifiedPort = req.getServerPort(); } else { identifiedPort = HtmlConsts.WEB_PORT; } } boolean expectedPort = (identifiedScheme.equalsIgnoreCase("http") && identifiedPort == HtmlConsts.WEB_PORT) || (identifiedScheme.equalsIgnoreCase("https") && identifiedPort == HtmlConsts.SECURE_WEB_PORT); String serverUrl; if (!expectedPort) { serverUrl = identifiedScheme + "://" + identifiedHostname + BasicConsts.COLON + Integer.toString(identifiedPort) + path; } else { serverUrl = identifiedScheme + "://" + identifiedHostname + path; } String query = req.getQueryString(); if (query == null) { if (req.getServletPath().equals("/demowebclient/greet")) { if (CLIENT_WEBSITE_CODESVR_PORT.length() != 0) { query = "gwt.codesvr=127.0.0.1:" + CLIENT_WEBSITE_CODESVR_PORT; } else { query = ""; } } else { query = ""; } } if (query.length() != 0) { query = "?" + query; } return serverUrl + BasicConsts.FORWARDSLASH + relativeServletPath + (preserveQS ? query : ""); }
From source file:de.hybris.platform.ytelcoacceleratorstorefront.interceptors.beforeview.AnalyticsPropertiesBeforeViewHandler.java
@Override public void beforeView(final HttpServletRequest request, final HttpServletResponse response, final ModelAndView modelAndView) { final String serverName = request.getServerName(); // Add config properties for google analytics addHostProperty(serverName, modelAndView, ThirdPartyConstants.Google.ANALYTICS_TRACKING_ID, "googleAnalyticsTrackingId"); // Add config properties for jirafe analytics addHostProperty(serverName, modelAndView, ThirdPartyConstants.Jirafe.API_URL, "jirafeApiUrl"); addHostProperty(serverName, modelAndView, ThirdPartyConstants.Jirafe.API_TOKEN, "jirafeApiToken"); addHostProperty(serverName, modelAndView, ThirdPartyConstants.Jirafe.APPLICATION_ID, "jirafeApplicationId"); addHostProperty(serverName, modelAndView, ThirdPartyConstants.Jirafe.VERSION, "jirafeVersion"); addHostProperty(serverName, modelAndView, ThirdPartyConstants.Jirafe.DATA_URL, "jirafeDataUrl"); // Lookup a currency specific jirafe site id first, and only if it is missing fallback to the default site id final String currencyIso = commonI18NService.getCurrentCurrency().getIsocode().toLowerCase(); final String currencySpecificJirafeSiteId = hostConfigService .getProperty(ThirdPartyConstants.Jirafe.SITE_ID + "." + currencyIso, serverName); if (org.apache.commons.lang.StringUtils.isNotBlank(currencySpecificJirafeSiteId)) { modelAndView.addObject("jirafeSiteId", currencySpecificJirafeSiteId); } else {//from w w w. j ava2s . c o m // Fallback to the non-currency specific value final String jirafeSiteId = hostConfigService.getProperty(ThirdPartyConstants.Jirafe.SITE_ID, serverName); modelAndView.addObject("jirafeSiteId", jirafeSiteId); } }
From source file:com.epam.cme.storefront.interceptors.beforeview.AnalyticsPropertiesBeforeViewHandler.java
@Override public void beforeView(final HttpServletRequest request, final HttpServletResponse response, final ModelAndView modelAndView) { final String serverName = request.getServerName(); // Add config properties for google analytics addHostProperty(serverName, modelAndView, ThirdPartyConstants.Google.ANALYTICS_TRACKING_ID, "googleAnalyticsTrackingId"); // Add config properties for jirafe analytics addHostProperty(serverName, modelAndView, ThirdPartyConstants.Jirafe.API_URL, "jirafeApiUrl"); addHostProperty(serverName, modelAndView, ThirdPartyConstants.Jirafe.API_TOKEN, "jirafeApiToken"); addHostProperty(serverName, modelAndView, ThirdPartyConstants.Jirafe.APPLICATION_ID, "jirafeApplicationId"); addHostProperty(serverName, modelAndView, ThirdPartyConstants.Jirafe.VERSION, "jirafeVersion"); addHostProperty(serverName, modelAndView, ThirdPartyConstants.Jirafe.DATA_URL, "jirafeDataUrl"); // Lookup a currency specific jirafe site id first, and only if it is missing fallback to // the default site id final String currencyIso = commonI18NService.getCurrentCurrency().getIsocode().toLowerCase(); final String currencySpecificJirafeSiteId = hostConfigService .getProperty(ThirdPartyConstants.Jirafe.SITE_ID + "." + currencyIso, serverName); if (org.apache.commons.lang.StringUtils.isNotBlank(currencySpecificJirafeSiteId)) { modelAndView.addObject("jirafeSiteId", currencySpecificJirafeSiteId); } else {/*from w ww .j a v a2 s. c o m*/ // Fallback to the non-currency specific value final String jirafeSiteId = hostConfigService.getProperty(ThirdPartyConstants.Jirafe.SITE_ID, serverName); modelAndView.addObject("jirafeSiteId", jirafeSiteId); } }
From source file:com.razorfish.controllers.pages.ChinaStoreLocatorPageController.java
@ModelAttribute("baiduMapApiKey") public String getBaiduMapApiKey(final HttpServletRequest request) { final String baiduMapApiKey = getHostConfigService().getProperty(BAIDU_API_KEY_ID, request.getServerName()); if (StringUtils.isEmpty(baiduMapApiKey)) { LOG.warn("No Baidu Map API key found for server: " + request.getServerName()); }// w w w . ja va 2 s .c o m return baiduMapApiKey; }
From source file:com.toughland.helpmechoose.common.Helper.java
public String getUrl(HttpServletRequest request) { return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/"; }