I've two websites, A and B. After I open website A, I'm rerouted to website B instantly.

What's the function that I'm able to check that which was the entire path of website A that was the redirect?

I had been trying to begin with:

        logger.info(request.getPathInfo());
        logger.info(request.getPathTranslated());
        logger.info(request.getServletPath());
        logger.info(request.getLocalName());
        logger.info(request.getRemoteAddr());
        logger.info(request.getRemoteHost());
        logger.info(request.getRequestURI());
        logger.info(request.getServerName());

but not one of them is correct.

For redirecting I personally use response.sendRedirect inside Controller.

Thank you for help.

You can test while using optional referer header:

request.getHeader("referer");

But you should observe that this might not necessarily be populated (particularly IE).

A much better solution, if you're in charge of each of those sites, would be to pass the worthiness in some way when doing the redirect. For instance, like a GET or Publish parameter.

Edit:

As recommended above, you are able to append query strings for your redirect URL. For instance, you could try something similar to this:

String redirectUrl = "http://my.redirect.com/";

redirectUrl += "?referer=";
redirectUrl += URLEncoder.encode(request.getRequestURL().toString(), "UTF-8");

You'll be able to just pull this from the request on the other hand.

Make use of this like a beginning point. You may want to by hand append other query parameters that won't participate the getRequestURL() output.

None of those would enable you to get the page that rerouted you to the present page. What you could try is:

String refererPage = request.getHeader("referer");

However bear in mind that this is browser dependent and could not necessarily show up.

Do this

request.getHeader("referer");

Please try

request.getHeader("referer");