Tabnine Logo
HttpServletRequest.getRemoteAddr
Code IndexAdd Tabnine to your IDE (free)

How to use
getRemoteAddr
method
in
javax.servlet.http.HttpServletRequest

Best Java code snippets using javax.servlet.http.HttpServletRequest.getRemoteAddr (Showing top 20 results out of 8,685)

Refine searchRefine arrow

  • HttpServletRequest.getHeader
  • HttpServletRequest.getRequestURI
  • HttpServletRequest.getMethod
  • HttpServletRequest.getRemoteHost
  • HttpServletRequest.getQueryString
origin: alibaba/druid

protected String getRemoteAddress(HttpServletRequest request) {
  String remoteAddress = null;
  
  if (remoteAddressHeader != null) {
    remoteAddress = request.getHeader(remoteAddressHeader);
  }
  
  if (remoteAddress == null) {
    remoteAddress = request.getRemoteAddr();
  }
  
  return remoteAddress;
}
origin: spring-projects/spring-framework

@Override
public String getDescription(boolean includeClientInfo) {
  HttpServletRequest request = getRequest();
  StringBuilder sb = new StringBuilder();
  sb.append("uri=").append(request.getRequestURI());
  if (includeClientInfo) {
    String client = request.getRemoteAddr();
    if (StringUtils.hasLength(client)) {
      sb.append(";client=").append(client);
    }
    HttpSession session = request.getSession(false);
    if (session != null) {
      sb.append(";session=").append(session.getId());
    }
    String user = request.getRemoteUser();
    if (StringUtils.hasLength(user)) {
      sb.append(";user=").append(user);
    }
  }
  return sb.toString();
}
origin: apache/incubator-dubbo

@Override
public void handle(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
  String uri = request.getRequestURI();
  HttpInvokerServiceExporter skeleton = skeletonMap.get(uri);
  if (!request.getMethod().equalsIgnoreCase("POST")) {
    response.setStatus(500);
  } else {
    RpcContext.getContext().setRemoteAddress(request.getRemoteAddr(), request.getRemotePort());
    try {
      skeleton.handleRequest(request, response);
    } catch (Throwable e) {
      throw new ServletException(e);
    }
  }
}
origin: apache/incubator-dubbo

@Override
public void handle(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
  String uri = request.getRequestURI();
  HessianSkeleton skeleton = skeletonMap.get(uri);
  if (!request.getMethod().equalsIgnoreCase("POST")) {
    response.setStatus(500);
  } else {
    RpcContext.getContext().setRemoteAddress(request.getRemoteAddr(), request.getRemotePort());
    Enumeration<String> enumeration = request.getHeaderNames();
    while (enumeration.hasMoreElements()) {
      String key = enumeration.nextElement();
      if (key.startsWith(Constants.DEFAULT_EXCHANGER)) {
        RpcContext.getContext().setAttachment(key.substring(Constants.DEFAULT_EXCHANGER.length()),
            request.getHeader(key));
      }
    }
    try {
      skeleton.invoke(request.getInputStream(), response.getOutputStream());
    } catch (Throwable e) {
      throw new ServletException(e);
    }
  }
}
origin: azkaban/azkaban

public static HttpServletRequest getRequestWithNoUpstream(final String clientIp,
  final String sessionId,
  final String requestMethod) {
 final HttpServletRequest req = mock(HttpServletRequest.class);
 when(req.getRemoteAddr()).thenReturn(clientIp);
 when(req.getHeader("x-forwarded-for")).thenReturn(null);
 when(req.getMethod()).thenReturn(requestMethod);
 when(req.getContentType()).thenReturn("application/x-www-form-urlencoded");
 // Requires sessionId to be passed that is in the application's session cache
 when(req.getParameter("session.id")).thenReturn(sessionId);
 return req;
}
origin: org.apache.cxf/cxf-rt-transports-http

localName = request.getLocalName();
localPort = request.getLocalPort();
method = request.getMethod();
pathInfo = request.getPathInfo();
pathTranslated = request.getPathTranslated();
protocol = request.getProtocol();
queryString = request.getQueryString();
remoteAddr = request.getRemoteAddr();
remoteHost = request.getRemoteHost();
remotePort = request.getRemotePort();
remoteUser = request.getRemoteUser();
requestURI = request.getRequestURI();
requestURL = request.getRequestURL();
requestedSessionId = request.getRequestedSessionId();
origin: spring-projects/spring-framework

StringBuilder msg = new StringBuilder();
msg.append(prefix);
msg.append("uri=").append(request.getRequestURI());
  String queryString = request.getQueryString();
  if (queryString != null) {
    msg.append('?').append(queryString);
  String client = request.getRemoteAddr();
  if (StringUtils.hasLength(client)) {
    msg.append(";client=").append(client);
origin: apache/incubator-druid

private void handleAuthorizationCheckError(
  String errorMsg,
  HttpServletRequest servletRequest,
  HttpServletResponse servletResponse
)
{
 // Send out an alert so there's a centralized collection point for seeing errors of this nature
 log.makeAlert(errorMsg)
   .addData("uri", servletRequest.getRequestURI())
   .addData("method", servletRequest.getMethod())
   .addData("remoteAddr", servletRequest.getRemoteAddr())
   .addData("remoteHost", servletRequest.getRemoteHost())
   .emit();
 if (servletResponse.isCommitted()) {
  throw new ISE(errorMsg);
 } else {
  try {
   servletResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
  }
  catch (Exception e) {
   throw new RuntimeException(e);
  }
 }
}
origin: com.h2database/h2

String file = req.getPathInfo();
if (file == null) {
  resp.sendRedirect(req.getRequestURI() + "/");
  return;
} else if (file.startsWith("/")) {
String ifModifiedSince = req.getHeader("if-modified-since");
String hostAddr = req.getRemoteAddr();
file = app.processRequest(file, hostAddr);
session = app.getSession();
origin: nutzam/nutz

  public static String dumpBrief(HttpServletRequest request) {
    StringBuilder sb = new StringBuilder();
    Enumeration<?> en = request.getParameterNames();
    while (en.hasMoreElements()) {
      String name = (String) en.nextElement();
      sb.append(name);
      String v = request.getParameter(name);
      if (v != null) {
        sb.append("=");
        sb.append(v);
      }
      if (en.hasMoreElements())
        sb.append("&");
    }
    return String.format(    "%5s:%15s[%5s]%s",
                new Object[]{    request.getLocale().toString(),
                        request.getRemoteAddr(),
                        ((HttpServletRequest) request).getMethod(),
                        ((HttpServletRequest) request)    .getRequestURL()
                                        .toString()
                            + (sb.length() > 0    ? "?" + sb.toString()
                                      : "")});
  }
}
origin: graphhopper/graphhopper

String infoStr = httpReq.getRemoteAddr() + " " + httpReq.getLocale() + " " + httpReq.getHeader("User-Agent");
String logStr = httpReq.getQueryString() + " " + infoStr + " " + requestPoints + ", took:"
    + took + ", " + algoStr + ", " + weighting + ", " + vehicleStr;
origin: glyptodon/guacamole-client

/**
 * Construct a Credentials object with the given username, password,
 * and HTTP request.  The information is assigned to the various
 * storage objects, and the remote hostname and address is parsed out
 * of the request object.
 * 
 * @param username
 *     The username that was provided for authentication.
 * 
 * @param password
 *     The password that was provided for authentication.
 * 
 * @param request 
 *     The HTTP request associated with the authentication
 *     request.
 */
public Credentials(String username, String password, HttpServletRequest request) {
  this.username = username;
  this.password = password;
  this.request = request;
  // Set the remote address
  this.remoteAddress = request.getRemoteAddr();
  // Get the remote hostname
  this.remoteHostname = request.getRemoteHost();
  // If session exists get it, but don't create a new one.
  this.session = request.getSession(false);
}

origin: DSpace/DSpace

/**
 * Service Method for testing spiders against existing spider files.
 *
 * @param request
 * @return true|false if the request was detected to be from a spider.
 */
public boolean isSpider(HttpServletRequest request) {
  return isSpider(request.getRemoteAddr(),
          request.getHeader("X-Forwarded-For"),
          request.getRemoteHost(),
          request.getHeader("User-Agent"));
}
origin: apache/incubator-dubbo

@Override
public void handle(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
  String uri = request.getRequestURI();
  HessianSkeleton skeleton = skeletonMap.get(uri);
  if (!request.getMethod().equalsIgnoreCase("POST")) {
    response.setStatus(500);
  } else {
    RpcContext.getContext().setRemoteAddress(request.getRemoteAddr(), request.getRemotePort());
    Enumeration<String> enumeration = request.getHeaderNames();
    while (enumeration.hasMoreElements()) {
      String key = enumeration.nextElement();
      if (key.startsWith(Constants.DEFAULT_EXCHANGER)) {
        RpcContext.getContext().setAttachment(key.substring(Constants.DEFAULT_EXCHANGER.length()),
            request.getHeader(key));
      }
    }
    try {
      skeleton.invoke(request.getInputStream(), response.getOutputStream());
    } catch (Throwable e) {
      throw new ServletException(e);
    }
  }
}
origin: jenkinsci/jenkins

private String getClientIP(HttpServletRequest req) {
  String defaultAddress = req.getRemoteAddr();
  String forwarded = req.getHeader(X_FORWARDED_FOR);
  if (forwarded != null) {
    String[] hopList = forwarded.split(",");
    if (hopList.length >= 1) {
      return hopList[0];
    }
  }
  return defaultAddress;
}

origin: azkaban/azkaban

public static HttpServletRequest getRequestWithMultipleUpstreams(final String clientIp,
  final String upstreamIp, final String sessionId, final String requestMethod) {
 final HttpServletRequest req = mock(HttpServletRequest.class);
 when(req.getRemoteAddr()).thenReturn("2.2.2.2:9999");
 when(req.getHeader("x-forwarded-for")).thenReturn(upstreamIp + ",1.1.1.1,3.3.3.3:33333");
 when(req.getMethod()).thenReturn(requestMethod);
 when(req.getContentType()).thenReturn("application/x-www-form-urlencoded");
 // Requires sessionId to be passed that is in the application's session cache
 when(req.getParameter("session.id")).thenReturn(sessionId);
 return req;
}
origin: apache/incubator-dubbo

@Override
public void handle(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
  String uri = request.getRequestURI();
  HttpInvokerServiceExporter skeleton = skeletonMap.get(uri);
  if (!request.getMethod().equalsIgnoreCase("POST")) {
    response.setStatus(500);
  } else {
    RpcContext.getContext().setRemoteAddress(request.getRemoteAddr(), request.getRemotePort());
    try {
      skeleton.handleRequest(request, response);
    } catch (Throwable e) {
      throw new ServletException(e);
    }
  }
}
origin: haraldk/TwelveMonkeys

out.println("Remote address: " +  pRequest.getRemoteAddr());
out.println("Remote host name: " + pRequest.getRemoteHost());
out.println("Remote user: " + pRequest.getRemoteUser());
out.println();
out.println("Request Method: " + pRequest.getMethod());
out.println("Request Scheme: " + pRequest.getScheme());
out.println("Request URI: " + pRequest.getRequestURI());
out.println("Request URL: " + pRequest.getRequestURL().toString());
out.println("Request PathInfo: " + pRequest.getPathInfo());
origin: org.springframework/spring-web

StringBuilder msg = new StringBuilder();
msg.append(prefix);
msg.append("uri=").append(request.getRequestURI());
  String queryString = request.getQueryString();
  if (queryString != null) {
    msg.append('?').append(queryString);
  String client = request.getRemoteAddr();
  if (StringUtils.hasLength(client)) {
    msg.append(";client=").append(client);
origin: Atmosphere/atmosphere

.pathInfo(request.getPathInfo())
.contextPath(request.getContextPath())
.requestURI(request.getRequestURI())
.requestURL(request.getRequestURL().toString())
.method(request.getMethod())
.serverName(request.getServerName())
.serverPort(request.getServerPort())
.remoteAddr(request.getRemoteAddr())
.remoteHost(request.getRemoteHost())
.remotePort(request.getRemotePort())
.destroyable(isDestroyable)
javax.servlet.httpHttpServletRequestgetRemoteAddr

Popular methods of HttpServletRequest

  • getHeader
    Returns the value of the specified request header as a String. If the request did not include a head
  • getParameter
  • getRequestURI
    Returns the part of this request's URL from the protocol name up to the query string in the first li
  • getSession
    Returns the current HttpSession associated with this request or, if there is no current session and
  • getMethod
    Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT
  • getAttribute
  • getContextPath
    Returns the portion of the request URI that indicates the context of the request. The context path a
  • getQueryString
    Returns the query string that is contained in the request URL after the path. This method returns nu
  • setAttribute
  • getPathInfo
    Returns any extra path information associated with the URL the client sent when it made this request
  • getRequestURL
    Reconstructs the URL the client used to make the request. The returned URL contains a protocol, serv
  • getServletPath
    Returns the part of this request's URL that calls the servlet. This path starts with a "/" character
  • getRequestURL,
  • getServletPath,
  • getInputStream,
  • getParameterMap,
  • getCookies,
  • getServerName,
  • getHeaderNames,
  • getScheme,
  • getServerPort

Popular in Java

  • Making http requests using okhttp
  • setContentView (Activity)
  • runOnUiThread (Activity)
  • requestLocationUpdates (LocationManager)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now