Reputation: 176
I am trying to implement a google analytics like service. This service will be called by client side JS embedded in different applications.
In my service, I want to extract the URL of the caller application. Is there any way in which I can extract this information in my service rather than have the client side JS send it (client side is less preferable because of data safety issues) ?
Upvotes: 0
Views: 740
Reputation: 157
I think you want something like this:
For this add HttpServletRequest request in API argument and try this
String uri = request.getScheme() + "://" + // "http" + "://
request.getServerName() + // "localhost"
":" + request.getServerPort() + // ":" + "8080"
request.getRequestURI() + // "/employee"
(request.getQueryString() != null ? "?" +
request.getQueryString() : ""); // "?" + "lastname=Kumar&age=30"
Upvotes: 1