List of usage examples for javax.servlet.http HttpServletRequest getServerPort
public int getServerPort();
From source file:com.amediamanager.controller.VideoController.java
@RequestMapping(value = "/video/upload", method = RequestMethod.GET) public String videoUpload(ModelMap model, HttpServletRequest request, @ModelAttribute User user) { // Video redirect URL String redirectUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/video/ingest"; // Prepare S3 form upload VideoUploadFormSigner formSigner = new VideoUploadFormSigner( config.getProperty(ConfigProps.S3_UPLOAD_BUCKET), config.getProperty(ConfigProps.S3_UPLOAD_PREFIX), user, config, redirectUrl);//from w ww . j a v a 2 s .c om model.addAttribute("formSigner", formSigner); model.addAttribute("templateName", "video_upload"); return "base"; }
From source file:com.zimbra.cs.zimlet.ProxyServlet.java
@Override protected boolean isAdminRequest(HttpServletRequest req) { return req.getServerPort() == LC.zimbra_admin_service_port.intValue(); }
From source file:com.icesoft.faces.renderkit.IncludeRenderer.java
public void encodeBegin(FacesContext context, UIComponent component) throws IOException { if (context == null || component == null) { throw new NullPointerException("Null Faces context or component parameter"); }/*from w w w . j a v a2 s.com*/ // suppress rendering if "rendered" property on the component is // false. if (!component.isRendered()) { return; } String page = (String) component.getAttributes().get("page"); HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest(); URI absoluteURI = null; try { absoluteURI = new URI(request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getRequestURI()); URL includedURL = absoluteURI.resolve(page).toURL(); URLConnection includedConnection = includedURL.openConnection(); includedConnection.setRequestProperty("Cookie", "JSESSIONID=" + ((HttpSession) context.getExternalContext().getSession(false)).getId()); Reader contentsReader = new InputStreamReader(includedConnection.getInputStream()); try { StringWriter includedContents = new StringWriter(); char[] buf = new char[2000]; int len = 0; while ((len = contentsReader.read(buf)) > -1) { includedContents.write(buf, 0, len); } ((UIOutput) component).setValue(includedContents.toString()); } finally { contentsReader.close(); } } catch (Exception e) { if (log.isDebugEnabled()) { log.debug(e.getMessage()); } } super.encodeBegin(context, component); }
From source file:com.enonic.cms.web.main.UpgradeController.java
/** * Return the base path.//from w w w . j av a 2 s . c o m */ private String createBaseUrl(HttpServletRequest req) { StringBuffer str = new StringBuffer(); str.append(req.getScheme()).append("://").append(req.getServerName()); if (req.getServerPort() != 80) { str.append(":").append(req.getServerPort()); } str.append(req.getContextPath()); return str.toString(); }
From source file:org.dmb.trueprice.servlets.Download_servlet.java
/** * Permet de construire iconDataPath lors de la 1e requete * (iconDataPath initial rcupr dans init(config) ne contiens * que le chemin relatif d'accs au dossier des images sur le serveur) * @param request //from ww w . ja va2 s . c o m */ // private void buildIconURL(ServletRequest request) { private String buildIconURL(HttpServletRequest request) { String srvName = request.getServerName(); String srvPort = Integer.toString(request.getServerPort()); log.debug("[srvName : srvPort] >> [" + srvName + " : " + srvPort + "]"); // String srvPath = this.getServletContext().getServerInfo(); // log.debug("Try srvCtxt real path [/img] >> " + srvPath ); // // String realPath = this.getServletContext().getRealPath("/img"); // // log.debug("Try srvCtxt real path [/img] >> " + realPath ); // String out = this.getServletContext().getResourcePaths("/").toString(); // // log.debug(" PRINT srvCtxt ressources paths List for [/] >> \n\n" // + out + "\n\n" ); // log.debug("Icon Data Folder is >> " + iconDataPath ); // if ( ! iconDataPath.contains // (realPath) ) { // log.debug("Adding real path [/] >> " + realPath ); // iconDataPath = realPath + iconDataPath; // // } // log.debug("Finally, Icon Data Folder is >> " + iconDataPath ); // log.debug("Icon Data Path is >> " + iconDataPath); if (!iconDataPath.contains(srvName)) { // log.debug("Adding real path [/] >> " + realPath ); iconDataPath = "https://" + srvName + ":" + srvPort + iconDataPath; } log.info("Finally, Icon Data Path is >> " + iconDataPath); iconPathIsOK = true; return iconDataPath; }
From source file:com.jaeksoft.searchlib.web.AbstractServlet.java
private void buildUrls(HttpServletRequest request) throws MalformedURLException { serverBaseURL = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath()).toString(); StringBuilder sbUrl = new StringBuilder(request.getRequestURI()); String qs = request.getQueryString(); if (qs != null) { sbUrl.append('?'); sbUrl.append(qs);/* w w w . ja v a2s . com*/ } URL url = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), sbUrl.toString()); serverURL = url.toString(); }
From source file:com.sun.socialsite.web.filters.RedirectorFilter.java
private String getRedirectionUri(HttpServletRequest httpReq) { if (baseUri == null) { return null; }/* w ww.j a v a2 s.com*/ String serverName = httpReq.getServerName(); String scheme = httpReq.getScheme(); int port = httpReq.getServerPort(); for (String exception : exceptions) { if (httpReq.getServletPath().startsWith(exception)) { return null; } } if (serverName.equalsIgnoreCase(baseUri.getHost()) && scheme.equalsIgnoreCase(baseUri.getScheme()) && (port == basePort)) { return null; } else { log.debug(String.format("Redirecting Because ((%s != %s) || (%s != %s) || (%d != %d))", serverName, baseUri.getHost(), scheme, baseUri.getScheme(), port, basePort)); StringBuilder sb = new StringBuilder(baseUri.toString()); if (httpReq.getServletPath() != null) sb.append(httpReq.getServletPath()); if (httpReq.getPathInfo() != null) sb.append(httpReq.getPathInfo()); if (httpReq.getQueryString() != null) sb.append("?").append(httpReq.getQueryString()); return sb.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 ww .jav a 2 s . c o m*/ return scheme + "://" + serverName + port; }
From source file:org.b3mn.poem.handler.HandlerBase.java
protected String getServerPath(HttpServletRequest req) { return "http://" + req.getServerName() + ":" + String.valueOf(req.getServerPort()) + getRelativeServerPath(req); }
From source file:com.streamsets.lib.security.http.SSOUserAuthenticator.java
String getAuthCookieName(HttpServletRequest httpReq) { return SSOConstants.AUTHENTICATION_COOKIE_PREFIX + httpReq.getServerPort(); }