Class KawaServlet.Context

    • Constructor Detail

      • Context

        public Context​(javax.servlet.http.HttpServlet servlet,
                       javax.servlet.http.HttpServletRequest request,
                       javax.servlet.http.HttpServletResponse response)
    • Method Detail

      • 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()
      • getContextPath

        public java.lang.String getContextPath()
        Description copied from class: HttpRequestContext
        Returns the context path, relative to the server root. This is an initial substring of the HttpRequestContext.getRequestPath(). Like ServletContext#getContextPath, but ends with a '/'. The string getRequestURI() is the same as the concatenation of getContextPath(), getScriptPath(), and getLocalPath().
        Specified by:
        getContextPath in class HttpRequestContext
      • getServletPath

        public java.lang.String getServletPath()
      • getRequestHeaders

        public java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getRequestHeaders()
        Specified by:
        getRequestHeaders in class HttpRequestContext
      • getResponseStream

        public java.io.OutputStream getResponseStream()
        Description copied from class: HttpRequestContext
        Return an OutputStream for the result body. Multiple calls will return the same OutputStream.
        Specified by:
        getResponseStream in class HttpRequestContext
      • reset

        public boolean reset​(boolean headersAlso)
        Description copied from class: HttpRequestContext
        Try to reset (delete) any response generated so far.
        Specified by:
        reset in class HttpRequestContext
        Parameters:
        headersAlso - if response headers should also be reset.
        Returns:
        true on success, false if it's too late.
      • getResourceURL

        public java.net.URL getResourceURL​(java.lang.String path)
        Description copied from class: HttpRequestContext
        Returns 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:
        getResourceURL in class HttpRequestContext
      • sendResponseHeaders

        public void sendResponseHeaders​(int reasonCode,
                                        java.lang.String reasonPhrase,
                                        long responseLength)
                                 throws java.io.IOException
        Description copied from class: HttpRequestContext
        Send headers.
        Specified by:
        sendResponseHeaders in class HttpRequestContext
        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:
        java.io.IOException
      • log

        public void log​(java.lang.String message,
                        java.lang.Throwable ex)
        Specified by:
        log in class HttpRequestContext