List of usage examples for javax.servlet.http HttpServletRequest getScheme
public String getScheme();
From source file:edu.indiana.d2i.sloan.ui.LoginAction.java
/** * get server context/*from w ww. jav a 2 s . com*/ * * @return */ private String getServerContext() { HttpServletRequest request = getServletRequest(); final StringBuilder serverPath = new StringBuilder(); serverPath.append(request.getScheme() + "://"); serverPath.append(request.getServerName()); if (request.getServerPort() != 80) { serverPath.append(":" + request.getServerPort()); } serverPath.append(request.getContextPath()); return serverPath.toString(); }
From source file:org.hippoecm.frontend.util.RequestUtils.java
public static String getFarthestRequestScheme(HttpServletRequest request) { String[] schemes = getCommaSeparatedMultipleHeaderValues(request, "X-Forwarded-Proto"); if (schemes != null && schemes.length != 0) { return schemes[0].toLowerCase(); }/*from ww w. ja va2 s . c om*/ schemes = getCommaSeparatedMultipleHeaderValues(request, "X-Forwarded-Scheme"); if (schemes != null && schemes.length != 0) { return schemes[0].toLowerCase(); } String[] sslEnabledArray = getCommaSeparatedMultipleHeaderValues(request, "X-SSL-Enabled"); if (sslEnabledArray == null) { sslEnabledArray = getCommaSeparatedMultipleHeaderValues(request, "Front-End-Https"); } if (sslEnabledArray != null && sslEnabledArray.length != 0) { String sslEnabled = sslEnabledArray[0]; if (sslEnabled.equalsIgnoreCase("on") || sslEnabled.equalsIgnoreCase("yes") || sslEnabled.equals("1")) { return "https"; } } return request.getScheme(); }
From source file:no.kantega.publishing.api.taglibs.util.GetUrlTag.java
private void addSchemeServerAndContextPath(StringBuilder urlBuilder, HttpServletRequest request) { urlBuilder.append(request.getScheme()); urlBuilder.append("://"); urlBuilder.append(request.getServerName()); int serverPort = request.getServerPort(); if (serverPort != 80 && serverPort != 443) { urlBuilder.append(":"); urlBuilder.append(serverPort);/*ww w.jav a 2s . co m*/ } urlBuilder.append(request.getContextPath()); }
From source file:com.pontecultural.flashcards.DeckController.java
@RequestMapping(method = RequestMethod.GET) public String getUploadForm(HttpServletRequest req, Locale locale, Model model) { logger.info("List of decks"); // compute base URL to allow client to call us back. String baseURL = req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort() + req.getContextPath();/*from w w w . j a va 2s . c om*/ model.addAttribute("baseURL", baseURL); model.addAttribute("decks", jdbcFlashcardsDao.fetchAllDecks()); return "deckList"; }
From source file:company.gonapps.loghut.controller.LoginFormController.java
@RequestMapping(value = "/login_form.do", method = RequestMethod.GET) public String loginForm(HttpServletRequest request) throws Exception { HttpSession session = request.getSession(false); if (session == null) { return "admin/login_form"; }/*w w w.j a v a 2 s . c o m*/ return "redirect:" + request.getScheme() + "://" + request.getServerName() + getSettingDao().getSetting("admin.url") + "/index.do"; }
From source file:com.sdl.odata.controller.AbstractODataController.java
/** * In cases when {@link HttpServletRequest} is wrapped, request url will consist values from top wrapper now. * Instead of schema, port and server name from inner {@link org.apache.coyote.Request}. * Default case is when service is behind load balancer and {@link org.apache.catalina.filters.RemoteIpFilter} * is used for X-Forwarded headers.//from w ww .j a v a 2 s . c om * * @param request wrapped/original request. * @return request URL based on values from wrapping Request. */ private StringBuilder getRequestURL(HttpServletRequest request) { String scheme = request.getScheme(); int port = request.getServerPort(); if (port < 0) { port = DEFAULT_PORT_NUMBER; } StringBuilder url = new StringBuilder(); url.append(scheme); url.append("://"); url.append(request.getServerName()); if ((scheme.equals("http") && (port != DEFAULT_PORT_NUMBER)) || (scheme.equals("https") && (port != DEFAULT_SSL_PORT_NUMBER))) { url.append(':'); url.append(port); } url.append(request.getRequestURI()); return url; }
From source file:org.iplantc.phyloviewer.viewer.server.ParseTreeService.java
private String getViewURL(String id, HttpServletRequest request) { String viewURL = request.getScheme() + "://" + request.getServerName(); if (request.getServerPort() != 80) { viewURL += ":" + request.getServerPort(); }//w w w . j av a 2 s. c o m if (request.getContextPath().length() > 0) { viewURL += request.getContextPath(); } viewURL += "/view/tree/" + id; return viewURL; }
From source file:demo.rest.RestApi.java
private String getKmlUrl(HttpServletRequest request) { final String scheme = request.getScheme(); final String serverName = request.getServerName(); final int serverPort = request.getServerPort(); final String contextPath = request.getContextPath(); StringBuilder url = new StringBuilder(); url.append(scheme).append("://").append(serverName); if ((serverPort != 80) && (serverPort != 443)) { url.append(":").append(serverPort); }// www.j a v a 2s.c om url.append(contextPath).append("/api/kml/"); return url.toString(); }
From source file:com.glaf.core.util.RequestUtils.java
public static String getLocalHostAddress(HttpServletRequest request, boolean includePort) { String scheme = request.getScheme(); String serverName = request.getServerName(); String port = ""; if (includePort) { int p = request.getServerPort(); port = (p == 80) ? "" : ":" + p; }//w w w. j a va 2s. c om return scheme + "://" + serverName + port; }
From source file:org.jlibrary.web.servlet.JLibraryServlet.java
/** * Returns the root URL of this application. * /*from w w w .j av a2 s . c o m*/ * @param request Requets * * @return String root url */ protected String getRootURL(HttpServletRequest request) { String rootURL = request.getScheme() + "://" + request.getServerName() + ":" + request.getLocalPort() + request.getContextPath(); return rootURL; }