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 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.
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-08-07 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\u003eIt includes static fields \u003ccode\u003eDEFAULT_DEFERRED_URL\u003c/code\u003e and \u003ccode\u003eRUNNABLE_TASK_CONTENT_TYPE\u003c/code\u003e, defining the default URL and content type for deferred tasks, respectively.\u003c/p\u003e\n"],["\u003cp\u003eStatic methods like \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 during a deferred task's execution.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003emarkForRetry()\u003c/code\u003e method can be used to request a task retry, while \u003ccode\u003esetDoNotRetry(boolean value)\u003c/code\u003e allows control over whether a task should be retried upon failure.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eDeferredTaskContext\u003c/code\u003e class inherits methods from the \u003ccode\u003ejava.lang.Object\u003c/code\u003e class such as \u003ccode\u003eclone()\u003c/code\u003e, \u003ccode\u003eequals(Object)\u003c/code\u003e, \u003ccode\u003efinalize()\u003c/code\u003e, and \u003ccode\u003egetClass()\u003c/code\u003e.\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](https://docs.oracle.com/javase/8/docs/api/javax/servlet/http/HttpServletRequest.html) 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](https://docs.oracle.com/javase/8/docs/api/javax/servlet/http/HttpServletResponse.html) 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](https://docs.oracle.com/javase/8/docs/api/javax/servlet/http/HttpServlet.html) 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.DeferredTaskContext#com_google_appengine_api_taskqueue_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."]]