org.kohsuke.stapler
Class HttpResponses

java.lang.Object
  extended by org.kohsuke.stapler.HttpResponses

public class HttpResponses
extends java.lang.Object

Factory for HttpResponse.

Author:
Kohsuke Kawaguchi

Nested Class Summary
static class HttpResponses.HttpResponseException
           
 
Constructor Summary
HttpResponses()
           
 
Method Summary
static HttpResponses.HttpResponseException error(int code, java.lang.String errorMessage)
           
static HttpResponses.HttpResponseException error(int code, java.lang.Throwable cause)
           
static HttpResponses.HttpResponseException forbidden()
           
static HttpResponses.HttpResponseException forwardToPreviousPage()
          Redirects the user back to where he came from.
static ForwardToView forwardToView(java.lang.Class clazz, java.lang.String view)
           
static ForwardToView forwardToView(java.lang.Object it, java.lang.String view)
           
static HttpResponse html(java.lang.String literalHtml)
          Serves the literal HTML.
static HttpResponses.HttpResponseException notFound()
           
static HttpResponses.HttpResponseException ok()
           
static HttpResponse plainText(java.lang.String plainText)
          Serves the plain text.
static HttpRedirect redirectTo(java.lang.String url)
           
static HttpResponses.HttpResponseException redirectToContextRoot()
          Redirect to the context root
static HttpResponse redirectToDot()
          Redirect to "."
static HttpResponses.HttpResponseException redirectViaContextPath(java.lang.String relative)
           
static HttpResponse staticResource(java.net.URL resource)
          Serves a static resource specified by the URL.
static HttpResponse staticResource(java.net.URL resource, long expiration)
          Serves a static resource specified by the URL.
static HttpResponses.HttpResponseException status(int code)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpResponses

public HttpResponses()
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,
                                                        java.lang.String errorMessage)

error

public static HttpResponses.HttpResponseException error(int code,
                                                        java.lang.Throwable cause)

redirectViaContextPath

public static HttpResponses.HttpResponseException redirectViaContextPath(java.lang.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(java.lang.String url)
Parameters:
url - The URL to redirect to. If relative, relative to the page currently being served.

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(java.net.URL resource)
Serves a static resource specified by the URL. Short for staticResource(resource,0)


staticResource

public static HttpResponse staticResource(java.net.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

public static HttpResponse html(java.lang.String literalHtml)
Serves the literal HTML.


plainText

public static HttpResponse plainText(java.lang.String plainText)
Serves the plain text.


forwardToView

public static ForwardToView forwardToView(java.lang.Object it,
                                          java.lang.String view)

forwardToView

public static ForwardToView forwardToView(java.lang.Class clazz,
                                          java.lang.String view)


Copyright © 2012. All Rights Reserved.