List of usage examples for javax.servlet.http HttpServletRequest getScheme
public String getScheme();
From source file:org.hoteia.qalingo.core.service.AbstractUrlService.java
public String buildAbsoluteUrl(final RequestData requestData, final String relativeUrl) throws Exception { if (relativeUrl != null) { final HttpServletRequest request = requestData.getRequest(); String cleanedRelativeUrl = relativeUrl.replace(buildDefaultPrefix(requestData), ""); String absoluteUrl = buildDomainePathUrl(requestData); if (!cleanedRelativeUrl.startsWith("/")) { absoluteUrl = absoluteUrl + "/" + cleanedRelativeUrl; } else {// ww w.j a v a 2 s. c o m absoluteUrl = absoluteUrl + cleanedRelativeUrl; } if (request != null && !absoluteUrl.startsWith(request.getScheme() + "://")) { absoluteUrl = request.getScheme() + "://" + absoluteUrl; } return absoluteUrl; } return relativeUrl; }
From source file:com.sun.socialsite.web.filters.CustomizedPageCachingFilter.java
@Override protected String calculateKey(final HttpServletRequest req) { StringBuffer sb;//from www . j a v a2s . co m String queryString = null; /* * We want our keys to be absolute URLs (with scheme, hostname, etc) so that * they'll line-up with what our URLStrategy uses (which makes it easier for * other code to invalidate cache entries when an entity is updated). */ if (req.getAttribute("javax.servlet.include.request_uri") != null) { sb = new StringBuffer(); sb.append(req.getMethod()); sb.append("|"); sb.append(req.getScheme()).append("://").append(req.getServerName()); switch (req.getServerPort()) { case 80: if (req.getScheme().equalsIgnoreCase("http")) { break; } case 443: if (req.getScheme().equalsIgnoreCase("https")) { break; } default: sb.append(":").append(req.getServerPort()); } sb.append((String) (req.getAttribute("javax.servlet.include.request_uri"))); queryString = (String) (req.getAttribute("javax.servlet.include.query_string")); } else { sb = req.getRequestURL(); queryString = req.getQueryString(); } if (queryString != null) { sb.append("?").append(queryString); } String key = sb.toString(); log.trace("key=" + key); return key; }
From source file:com.sun.identity.saml2.plugins.SAML2IDPProxyFRImpl.java
private String buildReturnURL(String requestID, HttpServletRequest request) { String methodName = "buildReturnURL"; StringBuffer sb = new StringBuffer(); String baseURL = request.getScheme() + "://" + request.getHeader("host") + request.getRequestURI(); String qs = request.getQueryString(); if (qs != null && !qs.isEmpty()) { baseURL = baseURL + "?" + qs; }/*from w w w. j a v a 2 s. c om*/ StringBuffer retURL = new StringBuffer().append(baseURL); if (retURL.toString().indexOf("?") == -1) { retURL.append("?"); } else { retURL.append("&"); } retURL.append("requestID=").append(requestID); sb.append(retURL); String returnURL = sb.toString(); debugMessage(methodName, " ReturnURL is: " + returnURL); return returnURL; }
From source file:fr.xebia.cocktail.CocktailRssView.java
@Override protected List<Item> buildFeedItems(Map<String, Object> model, final HttpServletRequest request, HttpServletResponse response) throws Exception { Function<Cocktail, Item> cocktailToRssItem = new Function<Cocktail, Item>() { @Override/*from w w w.ja v a 2s .c o m*/ public Item apply(@Nullable Cocktail cocktail) { if (cocktail == null) { return null; } Item item = new Item(); item.setTitle(cocktail.getName()); Content content = new Content(); content.setValue(cocktail.getInstructionsAsHtml()); content.setType(Content.HTML); item.setContent(content); item.setLink(request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/cocktail/" + cocktail.getId()); return item; } }; return Lists.newArrayList(Iterables.transform(cocktails, cocktailToRssItem)); }
From source file:com.vmware.appfactory.common.base.AbstractController.java
/** * Get a full server path url including current web app context. * e.g. http(s)://(hostname)(:optional_port)/(web_context)/ * * @param request - a HttpServletRequest. * @return a server path url//w w w.j a v a2s . c o m */ protected String getFullContextPath(HttpServletRequest request) { if (request == null) { throw new IllegalArgumentException("request must NOT be null!"); } int port = request.getLocalPort(); final StringBuilder url = new StringBuilder(); /* http(s)://hostname */ url.append(request.getScheme()).append("://").append(request.getServerName()); if (port != 80) { /* http(s)://hostname:xxxx */ url.append(":" + port); } /* http(s)://hostname(:xxxx)/web_context/ */ url.append(request.getContextPath()).append("/"); return url.toString(); }
From source file:com.viewer.controller.ViewerController.java
@RequestMapping(value = "/GetApplicationHost", method = RequestMethod.GET, headers = { "Content-type=application/json" }) @ResponseBody/*from w ww . j ava 2 s .c om*/ private String GetApplicationHost(@RequestBody HttpServletRequest request) { return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort(); }
From source file:at.gv.egiz.pdfas.web.helper.PdfAsHelper.java
private static String generateURL(HttpServletRequest request, HttpServletResponse response, String Servlet) { HttpSession session = request.getSession(); String publicURL = WebConfiguration.getPublicURL(); String dataURL = null;//www . j ava 2 s . c o m if (publicURL != null) { dataURL = publicURL + Servlet + ";jsessionid=" + session.getId(); } else { if ((request.getScheme().equals("http") && request.getServerPort() == 80) || (request.getScheme().equals("https") && request.getServerPort() == 443)) { dataURL = request.getScheme() + "://" + request.getServerName() + request.getContextPath() + Servlet + ";jsessionid=" + session.getId(); } else { dataURL = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + Servlet + ";jsessionid=" + session.getId(); } } logger.debug("Generated URL: " + dataURL); return dataURL; }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSMWar.CFAsteriskSMWarLoginHtml.java
protected void sendPasswordResetEMail(HttpServletRequest request, ICFSecuritySecUserObj resetUser, ICFSecurityClusterObj cluster) throws IOException, MessagingException, NamingException { String clusterDescription = cluster.getRequiredDescription(); String thisURI = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getRequestURI().toString(); int lastSlash = thisURI.lastIndexOf('/'); String baseURI = thisURI.substring(0, lastSlash); UUID resetUUID = resetUser.getOptionalPasswordResetUuid(); String msgBody = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n" + "<HTML>\n" + "<BODY>\n" + "<p>\n" + "You requested a password reset for " + resetUser.getRequiredEMailAddress() + " used for accessing " + clusterDescription + ".\n" + "<p>" + "Please click on the following link to reset your password:<br>\n" + "<A HRef=\"" + baseURI + "/CFAsteriskSMWarResetPasswordHtml?ResetUUID=" + resetUUID.toString() + "\">" + baseURI + "/CFAsteriskSMWarResetPasswordHtml?ResetUUID=" + resetUUID.toString() + "</A>\n" + "<p>" + "Or click on the following link to cancel the reset request:<br>\n" + "<A HRef=\"" + baseURI + "/CFAsteriskSMWarCancelResetPasswordHtml?ResetUUID=" + resetUUID.toString() + "\">" + baseURI + "/CFAsteriskSMWarCancelResetPasswordHtml?ResetUUID=" + resetUUID.toString() + "</A>\n" + "</BODY>\n" + "</HTML>\n"; CFAsteriskSMWarUtil warUtil = new CFAsteriskSMWarUtil(); warUtil.sendEMailToUser(resetUser,//from ww w. ja v a2 s . c o m "You requested a password reset for your account with " + clusterDescription + "?", msgBody); }
From source file:it.cnr.icar.eric.server.interfaces.soap.RegistryBSTServlet.java
@SuppressWarnings("unused") public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/plain"); String requestUri = req.getRequestURI(); String servletPath = req.getServletPath(); String scheme = req.getScheme(); String serverName = req.getServerName(); String queryString = req.getQueryString(); String ericName = RegistryProperties.getInstance().getProperty("eric.name", "eric"); int serverPort = req.getServerPort(); StringBuffer sb = new StringBuffer(); sb.append(scheme).append("://").append(serverName).append(':'); sb.append(serverPort);//from w w w.j a v a 2s .c o m sb.append('/'); sb.append(ericName); sb.append("/registry/thin/browser.jsp"); String url = sb.toString(); PrintWriter wt = resp.getWriter(); wt.println(ServerResourceBundle.getInstance().getString("message.urlForSOAP")); wt.println(ServerResourceBundle.getInstance().getString("message.urlForWebAccess", new Object[] { url })); wt.flush(); wt.close(); }