List of usage examples for javax.servlet.http HttpServletRequest getServerPort
public int getServerPort();
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 a v a 2 s . c o m*/ if (request.getContextPath().length() > 0) { viewURL += request.getContextPath(); } viewURL += "/view/tree/" + id; return viewURL; }
From source file:org.jm.spring.controller.EndpointDocumentationController.java
/** * Construct base path/*from www . ja v a2 s. com*/ * * @param httpServletRequest * @return */ private String getBasePath(HttpServletRequest httpServletRequest) { String scheme = httpServletRequest.getScheme(); // http String serverName = httpServletRequest.getServerName(); // hostname.com int serverPort = httpServletRequest.getServerPort(); // 80 StringBuffer basePath = new StringBuffer(); basePath.append(scheme).append("://").append(serverName); if (serverPort != 80) { basePath.append(":").append(serverPort); } return basePath.toString(); }
From source file:org.ow2.chameleon.everest.servlet.EverestServlet.java
/** * Computes the HTTP url of the given path. * The url is computed thanks to the request. * @param request the HTTP Request/*from w w w.j a v a 2 s . co m*/ * @param path the path * @return the URL pointing to the given path */ private String toURL(HttpServletRequest request, Path path) { return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + EVEREST_SERVLET_PATH + "/" + path.toString(); }
From source file:org.ow2.chameleon.everest.servlet.RelationSerializationTest.java
@Test public void testRelationWithoutParameter() throws IllegalResourceException, IOException { HttpServletRequest request = mock(HttpServletRequest.class); when(request.getScheme()).thenReturn("http"); when(request.getServerName()).thenReturn("server"); when(request.getServerPort()).thenReturn(1234); Relation relation = new DefaultRelation(Path.from("/foo/bar"), Action.READ, "test", "description"); Resource resource = new DefaultResource.Builder().fromPath(Path.from("/foo")).with(relation).build(); EverestServlet servlet = new EverestServlet(); JsonNode node = servlet.toJSON(request, resource); System.out.println(node);// ww w.j a va 2 s . c om assertThat(node.get("__relations")).isNotNull(); final JsonNode rel = node.get("__relations").get("test"); assertThat(rel).isNotNull(); assertThat(rel.get("href").asText()).isEqualTo("http://server:1234/everest/foo/bar"); assertThat(rel.get("action").asText()).isEqualTo("READ"); assertThat(rel.get("name").asText()).isEqualTo("test"); assertThat(rel.get("description").asText()).isEqualTo("description"); }
From source file:com.bitium.confluence.saml.SAMLContext.java
private String getDefaultBaseURL(HttpServletRequest request) { StringBuilder sb = new StringBuilder(); sb.append(request.getScheme()).append("://").append(request.getServerName()).append(":") .append(request.getServerPort()); sb.append(request.getContextPath()); return sb.toString(); }
From source file:eu.scape_project.pw.idp.bean.CreateAccountView.java
/** * Adds the user.//from w w w.j a v a 2 s . c om */ public void addUser() { userManager.addUser(user); HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext() .getRequest(); String serverString = request.getServerName() + ":" + request.getServerPort(); try { userManager.sendActivationMail(user, serverString); addUserSuccessful = true; } catch (CannotSendMailException e) { facesMessages.addError("Could not send activation mail."); addUserSuccessful = false; } }
From source file:org.ow2.chameleon.everest.servlet.RelationSerializationTest.java
@Test public void testRelationWithOneParameter() throws IllegalResourceException, IOException { HttpServletRequest request = mock(HttpServletRequest.class); when(request.getScheme()).thenReturn("http"); when(request.getServerName()).thenReturn("server"); when(request.getServerPort()).thenReturn(1234); Relation relation = new DefaultRelation(Path.from("/foo/bar"), Action.READ, "test", "description", new DefaultParameter().name("param").description("my param").type(String.class)); Resource resource = new DefaultResource.Builder().fromPath(Path.from("/foo")).with(relation).build(); EverestServlet servlet = new EverestServlet(); JsonNode node = servlet.toJSON(request, resource); System.out.println(node);// w w w .j av a 2 s . c o m assertThat(node.get("__relations")).isNotNull(); final JsonNode rel = node.get("__relations").get("test"); assertThat(rel).isNotNull(); assertThat(rel.get("href").asText()).isEqualTo("http://server:1234/everest/foo/bar"); assertThat(rel.get("action").asText()).isEqualTo("READ"); assertThat(rel.get("name").asText()).isEqualTo("test"); assertThat(rel.get("description").asText()).isEqualTo("description"); final JsonNode param0 = rel.get("parameters").get(0); assertThat(param0.get("name").asText()).isEqualTo("param"); assertThat(param0.get("description").asText()).isEqualTo("my param"); assertThat(param0.get("type").asText()).isEqualTo(String.class.getName()); assertThat(param0.get("optional").asBoolean()).isFalse(); }
From source file:com.glaf.core.util.RequestUtils.java
public static String getServiceUrl(HttpServletRequest request) { String scheme = request.getScheme(); String serviceUrl = scheme + "://" + request.getServerName(); if (request.getServerPort() != 80) { serviceUrl += ":" + request.getServerPort(); }/*from w w w . ja v a 2s. c om*/ if (!"/".equals(request.getContextPath())) { serviceUrl += request.getContextPath(); } return serviceUrl; }
From source file:edu.indiana.d2i.sloan.ui.LoginAction.java
/** * get server context//from w w w . ja va 2 s .co m * * @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:com.education.lessons.ui.server.login.OpenIDLoginController.java
/** * Builds the current base URL; up to the the domain name, e.g. * http://www.mydomain.com//*w w w . j av a 2s. c o m*/ */ private String getRealm(HttpServletRequest request) { String scheme = request.getScheme(); String serverName = request.getServerName(); int serverPort = request.getServerPort(); StringBuilder sb = new StringBuilder(); sb.append(scheme).append("://").append(serverName); if (serverPort != 80) { sb.append(":").append(serverPort); } sb.append("/"); return sb.toString(); }