Package org.kohsuke.stapler
Class HttpResponses
- java.lang.Object
-
- org.kohsuke.stapler.HttpResponses
-
public class HttpResponses extends Object
Factory forHttpResponse
.- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
HttpResponses.ErrorCustomizer
static class
HttpResponses.HttpResponseException
-
Constructor Summary
Constructors Constructor Description HttpResponses()
-
Method Summary
-
-
-
Method Detail
-
ok
public static HttpResponses.HttpResponseException ok()
-
notFound
public static HttpResponses.HttpResponseException notFound()
-
forbidden
public static HttpResponses.HttpResponseException forbidden()
-
status
public static HttpResponses.HttpResponseException status(int code)
-
error
public static HttpResponses.HttpResponseException error(int code, String errorMessage)
Sends an error with a stack trace.- See Also:
errorWithoutStack(int, java.lang.String)
-
error
public static HttpResponses.HttpResponseException error(Throwable cause)
-
error
public static HttpResponses.HttpResponseException error(int code, Throwable cause)
-
errorWithoutStack
public static HttpResponses.HttpResponseException errorWithoutStack(int code, String errorMessage)
Sends an error without a stack trace.- Since:
- 1.215
- See Also:
error(int, String)
-
redirectViaContextPath
public static HttpResponses.HttpResponseException redirectViaContextPath(String relative)
-
redirectViaContextPath
public static HttpResponses.HttpResponseException redirectViaContextPath(int statusCode, String relative)
- Parameters:
relative
- The path relative to the context path. The context path + this value is sent to the user.
-
redirectTo
public static HttpRedirect redirectTo(String url)
- Parameters:
url
- The URL to redirect to. If relative, relative to the page currently being served.
-
redirectTo
public static HttpRedirect redirectTo(int statusCode, String url)
-
redirectToDot
public static HttpResponse redirectToDot()
Redirect to "."
-
redirectToContextRoot
public static HttpResponses.HttpResponseException redirectToContextRoot()
Redirect to the context root
-
forwardToPreviousPage
public static HttpResponses.HttpResponseException forwardToPreviousPage()
Redirects the user back to where he came from.
-
staticResource
public static HttpResponse staticResource(URL resource)
Serves a static resource specified by the URL. Short forstaticResource(resource,0)
-
staticResource
public static HttpResponse staticResource(URL resource, long expiration)
Serves a static resource specified by the URL.- Parameters:
resource
- The static resource to be served.expiration
- The number of milliseconds until the resource will "expire". Until it expires the browser will be allowed to cache it and serve it without checking back with the server. After it expires, the client will send conditional GET to check if the resource is actually modified or not. If 0, it will immediately expire.
-
html
@Deprecated public static HttpResponse html(String literalHtml)
Deprecated.Adds a platform-specific newline; preferliteralHtml(java.lang.String)
.
-
literalHtml
public static HttpResponse literalHtml(String text)
Serves an HTML response.
-
plainText
@Deprecated public static HttpResponse plainText(String plainText)
Deprecated.Adds a platform-specific newline; prefertext(java.lang.String)
.
-
text
public static HttpResponse text(String text)
Serves a plain text response.
-
forwardToView
public static ForwardToView forwardToView(Object it, String view)
-
forwardToView
public static ForwardToView forwardToView(Class clazz, String view)
-
-