Top Description Methods
jakarta.servlet

public Interface ServletConnection


Provides information about the connection made to the Servlet container. This interface is intended primarily for debugging purposes and as such provides the raw information as seen by the container. Unless explicitly stated otherwise in the Javadoc for a method, no adjustment is made for the presence of reverse proxies or similar configurations.
Since
Servlet 6.0

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

A unique identifier for the network connection
getConnectionId
()

Obtain a unique (within the lifetime of the JVM) identifier string for the network connection to the JVM that is being used for the ServletRequest from which this ServletConnection was obtained.

public String

Returns:

The name of the protocol presented to the server after decryption of TLS, or similar encryption, if any.
getProtocol
()

Obtain the name of the protocol as presented to the server after the removal, if present, of any TLS or similar encryption.

public String

Returns:

The connection identifier if one is defined, otherwise an empty string
getProtocolConnectionId
()

Obtain the connection identifier for the network connection to the server that is being used for the ServletRequest from which this ServletConnection was obtained as defined by the protocol in use.

public boolean

Returns:

true if the incoming network connection used encryption, otherwise false
isSecure
()

Determine whether or not the incoming network connection to the server used encryption or not.

Method Detail

getConnectionIdback to summary
public String getConnectionId()

Obtain a unique (within the lifetime of the JVM) identifier string for the network connection to the JVM that is being used for the ServletRequest from which this ServletConnection was obtained.

There is no defined format for this string. The format is implementation dependent.

Returns:String

A unique identifier for the network connection

getProtocolback to summary
public String getProtocol()

Obtain the name of the protocol as presented to the server after the removal, if present, of any TLS or similar encryption. This may not be the same as the protocol seen by the application. For example, a reverse proxy may present AJP whereas the application will see HTTP 1.1.

If the protocol has an entry in the IANA registry for ALPN names then the identification sequence, in string form, must be returned. Registered identification sequences MUST only be used for the associated protocol. Return values for other protocols are implementation dependent. Unknown protocols should return the string "unknown".

Returns:String

The name of the protocol presented to the server after decryption of TLS, or similar encryption, if any.

getProtocolConnectionIdback to summary
public String getProtocolConnectionId()

Obtain the connection identifier for the network connection to the server that is being used for the ServletRequest from which this ServletConnection was obtained as defined by the protocol in use. Note that some protocols do not define such an identifier.

Examples of protocol provided connection identifiers include:

HTTP 1.x
None, so the empty string should be returned
HTTP 2
None, so the empty string should be returned
HTTP 3
The QUIC connection ID
AJP
None, so the empty string should be returned
Returns:String

The connection identifier if one is defined, otherwise an empty string

isSecureback to summary
public boolean isSecure()

Determine whether or not the incoming network connection to the server used encryption or not. Note that where a reverse proxy is used, the application may have a different view as to whether encryption is being used due to the use of headers like X-Forwarded-Proto.

Returns:boolean

true if the incoming network connection used encryption, otherwise false