Top Description Methods
jakarta.servlet.http

public Interface PushBuilder

Known Direct Implementers
org.apache.catalina.core.ApplicationPushBuilder
Imports
java.util.Set

Builds a push request based on the HttpServletRequest from which this builder was obtained. The push request will be constructed on the following basis:
Since
Servlet 4.0

Method Summary

Modifier and TypeMethod and Description
public PushBuilder

Returns:

This builder instance
addHeader
(String
The name of the header to add
name
,
String
The value of the header to add
value
)

Adds an HTTP header to the request.

public String

Returns:

The value of the given header. If multiple values are defined then any may be returned
getHeader
(String
The name of the header whose value is to be returned
name
)

Obtain a value for the given HTTP header.

public Set<String>

Returns:

The current set of names of HTTP headers to be used the next time push() is called.
getHeaderNames
()

public String

Returns:

The HTTP method to be used for future push requests
getMethod
()

Obtain the name of the HTTP method that will be used for push requests generated by future calls to push().

public String

Returns:

The path value that will be associated with the next push request
getPath
()

Obtain the path that will be used for the push request that will be generated by the next call to push().

public String

Returns:

The query string that will be appended to push requests.
getQueryString
()

Obtain the query string that will be used for push requests generated by future calls to push().

public String

Returns:

The session that will be used for push requests.
getSessionId
()

Obtain the session ID that will be used for push requests generated by future calls to push().

public PushBuilder

Returns:

This builder instance
method
(String
The method to use for the push request
method
)

Specify the HTTP method to use for the push request.

public PushBuilder

Returns:

This builder instance
path
(String
Paths beginning with '/' are treated as absolute paths. All other paths are treated as relative to the context path of the request used to create this builder instance. The path may include a query string.
path
)

Sets the URI path to be used for the push request.

public void
push()

Generates the push request and sends it to the client unless pushes are not available for some reason.

public PushBuilder

Returns:

This builder instance
queryString
(String
The query string to use to generate push requests
queryString
)

Specifies the query string to use in subsequent push requests generated by a call to push().

public PushBuilder

Returns:

This builder instance
removeHeader
(String
The name of the header to remove
name
)

Removes an HTTP header from the request.

public PushBuilder

Returns:

This builder instance
sessionId
(String
The session ID to use to generate push requests
sessionId
)

Specifies the session ID to use in subsequent push requests generated by a call to push().

public PushBuilder

Returns:

This builder instance
setHeader
(String
The name of the header to set
name
,
String
The value of the header to set
value
)

Sets an HTTP header on the request.

Method Detail

addHeaderback to summary
public PushBuilder addHeader(String name, String value)

Adds an HTTP header to the request.

Parameters
name:String

The name of the header to add

value:String

The value of the header to add

Returns:PushBuilder

This builder instance

getHeaderback to summary
public String getHeader(String name)

Obtain a value for the given HTTP header. TODO Servlet 4.0 Clarify the behaviour of this method

Parameters
name:String

The name of the header whose value is to be returned

Returns:String

The value of the given header. If multiple values are defined then any may be returned

getHeaderNamesback to summary
public Set<String> getHeaderNames()
Returns:Set<String>

The current set of names of HTTP headers to be used the next time push() is called.

getMethodback to summary
public String getMethod()

Obtain the name of the HTTP method that will be used for push requests generated by future calls to push().

Returns:String

The HTTP method to be used for future push requests

getPathback to summary
public String getPath()

Obtain the path that will be used for the push request that will be generated by the next call to push().

Returns:String

The path value that will be associated with the next push request

getQueryStringback to summary
public String getQueryString()

Obtain the query string that will be used for push requests generated by future calls to push().

Returns:String

The query string that will be appended to push requests.

getSessionIdback to summary
public String getSessionId()

Obtain the session ID that will be used for push requests generated by future calls to push().

Returns:String

The session that will be used for push requests.

methodback to summary
public PushBuilder method(String method)

Specify the HTTP method to use for the push request.

Parameters
method:String

The method to use for the push request

Returns:PushBuilder

This builder instance

Exceptions
IllegalArgumentException:
if an HTTP method is specified that is known not to be cacheable and safe. POST, PUT, DELETE, CONNECT, OPTIONS and TRACE will trigger the exception.
pathback to summary
public PushBuilder path(String path)

Sets the URI path to be used for the push request. This must be called before every call to push(). If the path includes a query string, the query string will be appended to the existing query string (if any) and no de-duplication will occur.

Parameters
path:String

Paths beginning with '/' are treated as absolute paths. All other paths are treated as relative to the context path of the request used to create this builder instance. The path may include a query string.

Returns:PushBuilder

This builder instance

pushback to summary
public void push()

Generates the push request and sends it to the client unless pushes are not available for some reason. After calling this method the following fields are set to null:

  • path
  • conditional request headers (if-none-match and if-modified-since)
Exceptions
IllegalStateException:
If this method is called when path is null
IllegalArgumentException:
If the request to push requires a body
queryStringback to summary
public PushBuilder queryString(String queryString)

Specifies the query string to use in subsequent push requests generated by a call to push(). This will be appended to any query string specified in the call to path(String).

Parameters
queryString:String

The query string to use to generate push requests

Returns:PushBuilder

This builder instance

removeHeaderback to summary
public PushBuilder removeHeader(String name)

Removes an HTTP header from the request.

Parameters
name:String

The name of the header to remove

Returns:PushBuilder

This builder instance

sessionIdback to summary
public PushBuilder sessionId(String sessionId)

Specifies the session ID to use in subsequent push requests generated by a call to push(). The session ID will be presented the same way as it is on the original request (cookie or URL parameter). The default is determined in the following order:

  • the requested session ID for the originating request
  • the session ID generated in the originated request
  • null
Parameters
sessionId:String

The session ID to use to generate push requests

Returns:PushBuilder

This builder instance

setHeaderback to summary
public PushBuilder setHeader(String name, String value)

Sets an HTTP header on the request. Any existing headers of the same name are first remove.

Parameters
name:String

The name of the header to set

value:String

The value of the header to set

Returns:PushBuilder

This builder instance