Example usage for javax.servlet.http HttpServletRequest getRemoteAddr

List of usage examples for javax.servlet.http HttpServletRequest getRemoteAddr

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getRemoteAddr.

Prototype

public String getRemoteAddr();

Source Link

Document

Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.

Usage

From source file:ru.org.linux.comment.AddCommentController.java

@ModelAttribute("ipBlockInfo")
private IPBlockInfo loadIPBlock(HttpServletRequest request) {
    return ipBlockDao.getBlockInfo(request.getRemoteAddr());
}

From source file:com.ksa.myanmarlottery.controller.ResultController.java

private String getRemoteAddress(HttpServletRequest request) {
    String ipAddress = request.getHeader("X-FORWARDED-FOR");
    if (ipAddress == null) {
        ipAddress = request.getRemoteAddr();
    }//ww w.j a va  2 s .  co  m
    log.debug("Remote Address " + request.getRemoteAddr());
    return ipAddress;
}

From source file:business.security.CustomLoggingInterceptor.java

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView model) throws Exception {
    log.trace(String.format("%s\t%s\t%s\t%s\t%s\t%d", new Date(), request.getRemoteAddr(),
            request.getUserPrincipal() == null ? " - " : request.getUserPrincipal().getName(),
            request.getMethod(), request.getRequestURI(), response.getStatus()));
    super.postHandle(request, response, handler, model);
}

From source file:com.epam.reportportal.auth.event.UiAuthenticationFailureEventHandler.java

private String getClientIP(HttpServletRequest request) {
    String xfHeader = request.getHeader(HttpHeaders.X_FORWARDED_FOR);
    if (xfHeader == null) {
        return request.getRemoteAddr();
    }/* w w  w .j a v  a  2s.  c  om*/
    return xfHeader.split(",")[0];
}

From source file:com.ikonoklastik.roller.ui.plugins.comments.recaptcha.ReCaptchaCommentAuthenticator.java

public boolean authenticate(HttpServletRequest request) {

    ReCaptcha captcha = ReCaptchaFactory.newReCaptcha(publicApiKey, privateApiKey, false);
    ReCaptchaResponse response = captcha.checkAnswer(request.getRemoteAddr(),
            request.getParameter("recaptcha_challenge_field"),
            request.getParameter("recaptcha_response_field"));

    if (!response.isValid()) {
        log.error(response.getErrorMessage());
    }/*from ww  w  .  j av  a2 s . c o  m*/

    return response.isValid();
}

From source file:com.webserviceInterceptor.CxfSoapInInterceptor.java

@Override
public void handleMessage(Message message) throws Fault {
    //get the remote address
    HttpServletRequest httpRequest = (HttpServletRequest) message.get(AbstractHTTPDestination.HTTP_REQUEST);
    System.out.println("Request From the address : " + httpRequest.getRemoteAddr());

    try {//w  w  w  . j  a v  a 2  s.  c om
        // now get the request xml
        InputStream is = message.getContent(InputStream.class);
        CachedOutputStream os = new CachedOutputStream();
        IOUtils.copy(is, os);
        os.flush();
        message.setContent(InputStream.class, os.getInputStream());
        is.close();

        LOGGER.info("The request is: " + IOUtils.toString(os.getInputStream()));
        os.close();
    }

    catch (Exception ex) {
        ex.printStackTrace();
    }

}

From source file:com.wmanual.web.controller.ManualHomeController.java

@RequestMapping("/")
public String home(HttpServletRequest request) throws Exception {
    logger.info("[{}] visit wmanual for {} page", request.getRemoteAddr(), "home");
    return "webmanual/index";
}

From source file:com.wmanual.web.controller.ManualHomeController.java

@RequestMapping("/index")
public String index(HttpServletRequest request) throws Exception {
    logger.info("[{}] visit wmanual for {} page", request.getRemoteAddr(), "index");
    return "webmanual/index";
}

From source file:com.wmanual.web.controller.ManualHomeController.java

@RequestMapping("/search")
public String search(HttpServletRequest request) throws Exception {
    logger.info("[{}] visit wmanual for {} page", request.getRemoteAddr(), "search");
    return "webmanual/search";
}

From source file:com.wmanual.web.controller.ManualHomeController.java

@RequestMapping("/yellowpage")
public String yellowpage(HttpServletRequest request) throws Exception {
    logger.info("[{}] visit wmanual for {} page", request.getRemoteAddr(), "yellowpage");
    return "yellowpage/yellowpage";
}