2.9.1 (latest) 2.9.0 2.8.1 2.7.2 2.6.0 2.5.1 2.4.1 2.1.2 2.0.1 1.35.2 1.34.1 1.33.4

    public class NotificationServlet extends HttpServlet

Beta   

Thread-safe Webhook Servlet to receive notifications using the `jakarta.servlet` namespace.

In order to use this servlet you should create a class inheriting from [NotificationServlet](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.extensions.servlet.notifications.jakarta.NotificationServlet) and register the servlet in your web.xml.

It is a simple wrapper around [WebhookUtils#processWebhookNotification](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.extensions.servlet.notifications.WebhookUtils#com_google_api_client_googleapis_extensions_servlet_notifications_WebhookUtils_processWebhookNotification_), so if you you
may alternatively call that method instead from your HttpServlet#doPost with no loss of
functionality. **Example usage:**


     public class MyNotificationServlet extends NotificationServlet {

       private static final long serialVersionUID = 1L;

       public MyNotificationServlet() throws IOException {
         super(new SomeDataStoreFactory());
       }
     }
     
**Sample web.xml setup:**


     {@literal <}servlet{@literal>}
     {@literal <}servlet-name{@literal>}MyNotificationServlet{@literal <} ervlet-name{@literal="">}
     {@literal <}servlet-class{@literal>}
         com.mypackage.MyNotificationServlet
     {@literal <} ervlet-class{@literal="">}
     {@literal <} ervlet{@literal="">}
     {@literal <}servlet-mapping{@literal>}
     {@literal <}servlet-name{@literal>}MyNotificationServlet{@literal <} ervlet-name{@literal="">}
     {@literal <}url-pattern{@literal>}/notifications{@literal <} rl-pattern{@literal="">}
     {@literal <} ervlet-mapping{@literal="">}
     
WARNING: by default it uses MemoryDataStoreFactory#getDefaultInstance() which means it
will NOT persist the notification channels when the servlet process dies, so it is a BAD CHOICE
for a production application. But it is a convenient choice when testing locally, in which case
you don't need to override it, and can simply reference it directly in your web.xml file. For
example:


     {@literal <}servlet{@literal>}
     {@literal <}servlet-name{@literal>}NotificationServlet{@literal <} ervlet-name{@literal="">}
     {@literal <}servlet-class{@literal>}
         com.google.api.client.googleapis.extensions.servlet.notificationsNotificationServlet
     {@literal <} ervlet-class{@literal="">}
     {@literal <} ervlet{@literal="">}
     {@literal <}servlet-mapping{@literal>}
     {@literal <}servlet-name{@literal>}NotificationServlet{@literal <} ervlet-name{@literal="">}
     {@literal <}url-pattern{@literal>}/notifications{@literal <} rl-pattern{@literal="">}
     {@literal <} ervlet-mapping{@literal="">}
     
## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> jakarta.servlet.GenericServlet \> jakarta.servlet.http.HttpServlet \> NotificationServlet

## Inherited Members

jakarta.servlet.GenericServlet.destroy() jakarta.servlet.GenericServlet.getInitParameter(java.lang.String) jakarta.servlet.GenericServlet.getInitParameterNames() jakarta.servlet.GenericServlet.getServletConfig() jakarta.servlet.GenericServlet.getServletContext() jakarta.servlet.GenericServlet.getServletInfo() jakarta.servlet.GenericServlet.getServletName() jakarta.servlet.GenericServlet.init() jakarta.servlet.GenericServlet.init(jakarta.servlet.ServletConfig) jakarta.servlet.GenericServlet.log(java.lang.String) jakarta.servlet.GenericServlet.log(java.lang.String,java.lang.Throwable) jakarta.servlet.http.HttpServlet.doDelete(jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse) jakarta.servlet.http.HttpServlet.doGet(jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse) jakarta.servlet.http.HttpServlet.doHead(jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse) jakarta.servlet.http.HttpServlet.doOptions(jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse) jakarta.servlet.http.HttpServlet.doPost(jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse) jakarta.servlet.http.HttpServlet.doPut(jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse) jakarta.servlet.http.HttpServlet.doTrace(jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse) jakarta.servlet.http.HttpServlet.getLastModified(jakarta.servlet.http.HttpServletRequest) jakarta.servlet.http.HttpServlet.service(jakarta.servlet.ServletRequest,jakarta.servlet.ServletResponse) jakarta.servlet.http.HttpServlet.service(jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse) [Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Constructors

### NotificationServlet()

    public NotificationServlet()

Constructor to be used for testing and demo purposes that uses MemoryDataStoreFactory#getDefaultInstance() which means it will NOT persist the notification
channels when the servlet process dies, so it is a bad choice for a production application.

### NotificationServlet(DataStore\<StoredChannel\> channelDataStore)

    protected NotificationServlet(DataStore<StoredChannel> channelDataStore)

Constructor that allows a specific notification data store to be specified.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `channelDataStore` | `com.google.api.client.util.store.DataStore<https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.notifications.StoredChannel>` notification channel data store |

### NotificationServlet(DataStoreFactory dataStoreFactory)

    protected NotificationServlet(DataStoreFactory dataStoreFactory)

Constructor which uses [StoredChannel#getDefaultDataStore(DataStoreFactory)](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.notifications.StoredChannel#com_google_api_client_googleapis_notifications_StoredChannel_getDefaultDataStore_com_google_api_client_util_store_DataStoreFactory_) on the given
data store factory, which is the normal use case.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `dataStoreFactory` | `com.google.api.client.util.store.DataStoreFactory` data store factory |

## Methods

### doPost(HttpServletRequest req, HttpServletResponse resp)

    protected void doPost(HttpServletRequest req, HttpServletResponse resp)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `req` | `jakarta.servlet.http.HttpServletRequest` |
| `resp` | `jakarta.servlet.http.HttpServletResponse` |

**Overrides** jakarta.servlet.http.HttpServlet.doPost(jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse)

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `jakarta.servlet.ServletException` |   |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |