I am building a plugin for a web application in java which is running on Tomcat and behind a apache reverse proxy server.
I am able to get the following:
Host Name : request.getLocalName()
Port: request.getLocalPort()
How can I get the following for original request, not for proxy request:
Request Scheme : ??
Context Path: ??
To get the authentication scheme used to protect the Servlet you can call from class HttpServletRequest
the method getAuthType()
. This will return values matching the static finals as specified in the javadocs.
Field Summary:
static String BASIC_AUTH
String identifier for Basic authentication.
static String CLIENT_CERT_AUTH
String identifier for Client Certificate authentication.
static String DIGEST_AUTH
String identifier for Digest authentication.
static String FORM_AUTH
String identifier for Form authentication.
To get the context path you would just call getContextPath()
of HttpServletRequest.
EDIT:
To get the local machine name of the server behind the proxy you could get the localhost machine name:
java.net.InetAddress localMachine = java.net.InetAddress.getLocalHost();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.