1

How can I get the service from a HttpServletRequest in Tomcat 8?

In tomcat 7 mapper is in the Connector so I was able to access the Mapper as

((Request) request).getConnector().getMapper() //request is a HttpServletRequest

But how can I obtain this in Tomcat 8? In the tomcat 8 migration documentation it is said that

The Mapper has moved from the Connector to the Service since the Mapper is identical for all Connectors of a given Service.

3 Answers3

2

The tomcat developers just moved the mapper to Service. So use:

((Request) request).getConnector().getService().getMapper()
René Link
  • 43,842
  • 12
  • 98
  • 127
0
public static String getFullURL(HttpServletRequest request) {
StringBuffer requestURL = request.getRequestURL();
String queryString = request.getQueryString();

if (queryString == null) {
    return requestURL.toString();
} else {
    return requestURL.append('?').append(queryString).toString();
}

}

malli
  • 85
  • 1
  • 7
0

Finally I figured the way I have to get the service from the Connector

getConnector().getService().getMapper()