Returns the HttpServletRequest instance for the current running deferred task for the
current thread or null if there is no current deferred task active for this thread.
Returns the HttpServletResponse instance for the current running deferred task for the
current thread or null if there is no current deferred task active for this thread.
Returns
Type
Description
jakarta.servlet.http.HttpServletResponse
getCurrentServlet()
publicstaticHttpServletgetCurrentServlet()
Returns the HttpServlet instance for the current running deferred task for the current
thread or null if there is no current deferred task active for this thread.
Returns
Type
Description
jakarta.servlet.http.HttpServlet
markForRetry()
publicstaticvoidmarkForRetry()
Request a retry of this task, even if an exception was not thrown. If an exception was thrown
and #setDoNotRetry is set to true the request will not be retried.
setDoNotRetry(boolean value)
publicstaticvoidsetDoNotRetry(booleanvalue)
Sets the action on task failure. Normally when an exception is thrown, the task will be
retried, however if setDoNotRetry is set to true, the task will not be retried.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-03 UTC."],[[["\u003cp\u003e\u003ccode\u003eDeferredTaskContext\u003c/code\u003e provides resources for managing \u003ccode\u003eDeferredTask\u003c/code\u003e within the Java App Engine environment.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eDEFAULT_DEFERRED_URL\u003c/code\u003e static field represents the default URL mapped to the \u003ccode\u003eDeferredTask\u003c/code\u003e servlet.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eRUNNABLE_TASK_CONTENT_TYPE\u003c/code\u003e static field specifies the content type of a serialized \u003ccode\u003eDeferredTask\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eStatic methods such as \u003ccode\u003egetCurrentRequest()\u003c/code\u003e, \u003ccode\u003egetCurrentResponse()\u003c/code\u003e, and \u003ccode\u003egetCurrentServlet()\u003c/code\u003e allow access to the current HTTP request, response, and servlet instances, respectively, when a deferred task is running.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003emarkForRetry()\u003c/code\u003e and \u003ccode\u003esetDoNotRetry(boolean value)\u003c/code\u003e methods are used to control task retry behavior, allowing developers to either request a retry or prevent it in case of exceptions.\u003c/p\u003e\n"]]],[],null,["# Class DeferredTaskContext (2.0.0)\n\n public class DeferredTaskContext\n\nResources for managing [DeferredTask](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.taskqueue.DeferredTask). \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e DeferredTaskContext \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nStatic Fields\n-------------\n\n### DEFAULT_DEFERRED_URL\n\n public static final String DEFAULT_DEFERRED_URL\n\nThe URL the DeferredTask servlet is mapped to by default.\n\n### RUNNABLE_TASK_CONTENT_TYPE\n\n public static final String RUNNABLE_TASK_CONTENT_TYPE\n\nThe content type of a serialized [DeferredTask](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.taskqueue.DeferredTask).\n\nStatic Methods\n--------------\n\n### getCurrentRequest()\n\n public static HttpServletRequest getCurrentRequest()\n\nReturns the HttpServletRequest instance for the current running deferred task for the\ncurrent thread or `null` if there is no current deferred task active for this thread.\n\n### getCurrentResponse()\n\n public static HttpServletResponse getCurrentResponse()\n\nReturns the HttpServletResponse instance for the current running deferred task for the\ncurrent thread or `null` if there is no current deferred task active for this thread.\n\n### getCurrentServlet()\n\n public static HttpServlet getCurrentServlet()\n\nReturns the HttpServlet instance for the current running deferred task for the current\nthread or `null` if there is no current deferred task active for this thread.\n\n### markForRetry()\n\n public static void markForRetry()\n\nRequest a retry of this task, even if an exception was not thrown. If an exception was thrown\nand [#setDoNotRetry](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.taskqueue.ee10.DeferredTaskContext#com_google_appengine_api_taskqueue_ee10_DeferredTaskContext_setDoNotRetry_) is set to `true` the request will not be retried.\n\n### setDoNotRetry(boolean value)\n\n public static void setDoNotRetry(boolean value)\n\nSets the action on task failure. Normally when an exception is thrown, the task will be\nretried, however if `setDoNotRetry` is set to `true`, the task will not be retried."]]