List of usage examples for javax.servlet.http HttpServletRequest getLocalPort
public int getLocalPort();
From source file:org.apache.hadoop.mapreduce.security.SecureShuffleUtils.java
/** * Shuffle specific utils - build string for encoding from URL * @param request//from w w w. j av a 2s . co m * @return string for encoding */ public static String buildMsgFrom(HttpServletRequest request) { return buildMsgFrom(request.getRequestURI(), request.getQueryString(), request.getLocalPort()); }
From source file:com.hangum.tadpole.engine.restful.RESTfulAPIUtils.java
/** * make url//ww w . j av a 2 s. c o m * * @param strSQL * @param strRestURL * @return */ public static String makeURL(String strSQL, String strRestURL) { HttpServletRequest httpRequest = RWT.getRequest(); String strServerURL = String.format("http://%s:%s%s", httpRequest.getLocalName(), httpRequest.getLocalPort(), httpRequest.getServletPath()); return String.format("%s%s?%s", strServerURL + "api/rest/base", strRestURL, getParameter(strSQL)); }
From source file:net.jadler.stubbing.server.jetty.RequestUtils.java
public static Request convert(HttpServletRequest source) throws IOException { String method = source.getMethod(); URI requestUri = URI.create(source.getRequestURL() + getQueryString(source)); InputStream body = source.getInputStream(); InetSocketAddress localAddress = new InetSocketAddress(source.getLocalAddr(), source.getLocalPort()); InetSocketAddress remoteAddress = new InetSocketAddress(source.getRemoteAddr(), source.getRemotePort()); String encoding = source.getCharacterEncoding(); Map<String, List<String>> headers = converHeaders(source); return new Request(method, requestUri, headers, body, localAddress, remoteAddress, encoding); }
From source file:com.beginner.core.utils.ProjectUtil.java
/** * ?Web???(?????)/*from w w w.ja va2s. co m*/ */ public static int port() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) .getRequest(); return request.getLocalPort(); }
From source file:de.qucosa.servlet.MetsDisseminatorServlet.java
private static String extractTargetUrlFromRequest(HttpServletRequest request) { return String.format("%s://%s:%s/fedora", request.getScheme(), request.getLocalName(), request.getLocalPort()); }
From source file:org.encuestame.core.util.InternetUtils.java
/** * Build Domain.// www .jav a 2s.c o m * @param request {@link HttpServletRequest}. * @return */ private static String getRequestDomain(final HttpServletRequest request) { final StringBuffer stringBuffer = new StringBuffer( InternetUtils.isSecure(request) ? "https://" : "http://"); stringBuffer.append(request.getServerName()); if (request.getRemotePort() != 80) { stringBuffer.append(":"); stringBuffer.append(request.getLocalPort()); } stringBuffer.append(request.getContextPath()); return stringBuffer.toString(); }
From source file:org.easyrec.util.core.Web.java
/** * This function returns a relative servlet url into a complete one. e.g. * /peppi?id=43 --> http://localhost:8080/sat-xxx/peppi?id=43 * * @param request HttpServletRequest/*from w ww . j a v a 2 s . c o m*/ * @param servlet String * @return String */ @SuppressWarnings({ "UnusedDeclaration" }) public static String createRequestFromServlet(HttpServletRequest request, String servlet) { return request.getScheme() + "://" + request.getLocalAddr() + ":" + request.getLocalPort() + request.getContextPath() + servlet; }
From source file:com.zimbra.cs.servlet.util.AuthUtil.java
/** * Checks to see if this is an admin request * @param req// w w w. ja va 2s .c o m * @return * @throws ServiceException */ public static boolean isAdminRequest(HttpServletRequest req) throws ServiceException { int adminPort = Provisioning.getInstance().getLocalServer().getIntAttr(Provisioning.A_zimbraAdminPort, -1); if (req.getLocalPort() == adminPort) { //can still be in offline server where port=adminPort int mailPort = Provisioning.getInstance().getLocalServer().getIntAttr(Provisioning.A_zimbraMailPort, -1); if (mailPort == adminPort) //we are in offline, so check cookie return getAdminAuthTokenFromCookie(req) != null; else return true; } return false; }
From source file:com.zimbra.cs.servlet.ZimbraServlet.java
protected static String getProxyUrl(HttpServletRequest req, Server server, String path) throws ServiceException { int servicePort = (req == null) ? -1 : req.getLocalPort(); Provisioning prov = Provisioning.getInstance(); Server localServer = prov.getLocalServer(); if (!prov.isOfflineProxyServer(server) && servicePort == localServer.getIntAttr(Provisioning.A_zimbraAdminPort, 0)) return URLUtil.getAdminURL(server, path); else//w w w . j a v a 2 s . c om return URLUtil.getServiceURL(server, path, servicePort == localServer.getIntAttr(Provisioning.A_zimbraMailSSLPort, 0)); }
From source file:org.easyrec.util.core.Web.java
/** * returns the complete path of the webapp e.g. * http://my.server.com/easyrec-web//*w ww . ja va2 s. c om*/ * * @param request HttpServletRequest * @return String */ public static String getExtendedWebappPath(HttpServletRequest request) { if (path == null) { String localName = request.getLocalName(); localName = localName.equals("0.0.0.0") ? "localhost" : localName; path = request.getScheme() + "://" + //request.getLocalAddr()+ ":" + localName + ":" + request.getLocalPort() + request.getContextPath(); } return path; }