Package gnu.kawa.servlet
Class KawaServlet.Context
java.lang.Object
gnu.kawa.servlet.HttpRequestContext
gnu.kawa.servlet.KawaServlet.Context
- Enclosing class:
KawaServlet
-
Field Summary
Fields inherited from class gnu.kawa.servlet.HttpRequestContext
HTTP_NOT_FOUND, HTTP_OK, importServletDefinitions, instance, statusCode, statusReasonPhrase -
Constructor Summary
ConstructorsConstructorDescriptionContext(javax.servlet.http.HttpServlet servlet, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) -
Method Summary
Modifier and TypeMethodDescriptiongetAttribute(String name) Get attribute from the server context.Returns the context path, relative to the server root.static javax.servlet.http.HttpServletRequeststatic javax.servlet.http.HttpServletResponsestatic KawaServlet.ContextgetInstance(String command) static KawaServlet.Contextintintjavax.servlet.http.HttpServletRequestgetRequestHeader(String name) getRequestHeaders(String name) getResourceURL(String path) Returns the URL of a resource.javax.servlet.http.HttpServletResponseReturn an OutputStream for the result body.javax.servlet.http.HttpServletjavax.servlet.ServletConfigjavax.servlet.ServletContextvoidvoidbooleanreset(boolean headersAlso) Try to reset (delete) any response generated so far.voidsendResponseHeaders(int reasonCode, String reasonPhrase, long responseLength) Send headers.voidsetAttribute(String name, Object value) Set attribute in the server context.voidsetContentType(String type) voidsetResponseHeader(String name, String value) Methods inherited from class gnu.kawa.servlet.HttpRequestContext
getConsumer, getInstance, getLocalPath, getLocalSocketAddress, getRemoteSocketAddress, getRequestBodyChars, getRequestParameter, getRequestPort, getScriptPath, handleStaticFile, normalizeToContext, sendNotFound, setInstance, setScriptAndLocalPath
-
Constructor Details
-
Context
public Context(javax.servlet.http.HttpServlet servlet, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
-
-
Method Details
-
getInstance
-
getInstanceOrNull
-
getCurrentRequest
public static javax.servlet.http.HttpServletRequest getCurrentRequest() -
getCurrentResponse
public static javax.servlet.http.HttpServletResponse getCurrentResponse() -
getServlet
public javax.servlet.http.HttpServlet getServlet() -
getRequest
public javax.servlet.http.HttpServletRequest getRequest() -
getResponse
public javax.servlet.http.HttpServletResponse getResponse() -
getServletConfig
public javax.servlet.ServletConfig getServletConfig() -
getServletContext
public javax.servlet.ServletContext getServletContext() -
getRequestURI
- Specified by:
getRequestURIin classHttpRequestContext
-
getContextPath
Description copied from class:HttpRequestContextReturns the context path, relative to the server root. This is an initial substring of theHttpRequestContext.getRequestPath(). LikeServletContext#getContextPath, but ends with a'/'. The stringgetRequestURI()is the same as the concatenation ofgetContextPath(),getScriptPath(), andgetLocalPath().- Specified by:
getContextPathin classHttpRequestContext
-
getQueryString
- Specified by:
getQueryStringin classHttpRequestContext
-
getRequestMethod
- Specified by:
getRequestMethodin classHttpRequestContext
-
getRequestPath
- Overrides:
getRequestPathin classHttpRequestContext
-
getRequestScheme
- Overrides:
getRequestSchemein classHttpRequestContext
-
getLocalHost
- Overrides:
getLocalHostin classHttpRequestContext
-
getLocalIPAddress
- Overrides:
getLocalIPAddressin classHttpRequestContext
-
getLocalPort
public int getLocalPort()- Specified by:
getLocalPortin classHttpRequestContext
-
getRemoteIPAddress
- Specified by:
getRemoteIPAddressin classHttpRequestContext
-
getRemoteHost
- Specified by:
getRemoteHostin classHttpRequestContext
-
getRemotePort
public int getRemotePort()- Specified by:
getRemotePortin classHttpRequestContext
-
getRequestURLBuffer
- Overrides:
getRequestURLBufferin classHttpRequestContext
-
getServletPath
-
getPathTranslated
- Specified by:
getPathTranslatedin classHttpRequestContext
-
getRequestParameters
- Specified by:
getRequestParametersin classHttpRequestContext
-
getRequestHeader
- Specified by:
getRequestHeaderin classHttpRequestContext
-
getRequestHeaders
- Specified by:
getRequestHeadersin classHttpRequestContext
-
getRequestHeaders
- Specified by:
getRequestHeadersin classHttpRequestContext
-
getRequestStream
- Specified by:
getRequestStreamin classHttpRequestContext
-
getResponseStream
Description copied from class:HttpRequestContextReturn an OutputStream for the result body. Multiple calls will return the same OutputStream.- Specified by:
getResponseStreamin classHttpRequestContext
-
setResponseHeader
- Specified by:
setResponseHeaderin classHttpRequestContext
-
setContentType
- Overrides:
setContentTypein classHttpRequestContext
-
reset
public boolean reset(boolean headersAlso) Description copied from class:HttpRequestContextTry to reset (delete) any response generated so far.- Specified by:
resetin classHttpRequestContext- Parameters:
headersAlso- if response headers should also be reset.- Returns:
- true on success, false if it's too late.
-
getResourceURL
Description copied from class:HttpRequestContextReturns the URL of a resource. The resource is relative to the script path, if the path is relative; otherwise (if it starts with a'/'it is relative to the context path.- Specified by:
getResourceURLin classHttpRequestContext
-
getAttribute
Description copied from class:HttpRequestContextGet attribute from the server context.- Specified by:
getAttributein classHttpRequestContext
-
setAttribute
Description copied from class:HttpRequestContextSet attribute in the server context.- Specified by:
setAttributein classHttpRequestContext
-
sendResponseHeaders
public void sendResponseHeaders(int reasonCode, String reasonPhrase, long responseLength) throws IOException Description copied from class:HttpRequestContextSend headers.- Specified by:
sendResponseHeadersin classHttpRequestContext- Parameters:
reasonCode- response code - e.g. 200 for OK.reasonPhrase- response string - e.g. "OK" or "Not Found".responseLength- response length in bytes, or -1 (unspecified). Note this is different from HttpExchange.sendResponseHeaders. This method must be called before getResponseStream. Implementations should set statusCode to STATUS_SENT.- Throws:
IOException
-
log
- Specified by:
login classHttpRequestContext
-
log
- Specified by:
login classHttpRequestContext
-