Class RequestDispatcher

java.lang.Object
com.codename1.backend.web.RequestDispatcher

public final class RequestDispatcher extends Object

The request attributes the server sets when it hands a request to the error page, under the names a servlet container uses, so an error controller ported from Spring Boot reads them unchanged:

@RequestMapping("/error")
public HttpServer.Response error(HttpServer.Request request) {
    Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
    Object path = request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI);
    ...
}

So are the errors the generated router answers itself -- a malformed target, a body or parameter it cannot bind (400), a content type the route does not consume (415) -- and an exception escaping a handler (500, or the status of a ResponseStatusException), each with its own status.

A request no route, file or NoHandlerFoundException handler answers is dispatched to the application's route for the error path -- /error, or cn1.server.error.path, empty to turn the dispatch off -- with these set, as Spring Boot forwards it to its ErrorController. Its answer is sent with status 404 unless it chose another one itself. With no route at that path the server's own plain-text 404 stands.

  • Field Details

    • ERROR_STATUS_CODE

      public static final String ERROR_STATUS_CODE
      The status the request would have been answered with, an Integer.
      See Also:
    • ERROR_REQUEST_URI

      public static final String ERROR_REQUEST_URI
      The path of the request as it arrived, without its query, a String.
      See Also:
    • ERROR_MESSAGE

      public static final String ERROR_MESSAGE
      A short description of the failure, a String.
      See Also:
    • ERROR_METHOD

      public static final String ERROR_METHOD
      The method of the request as it arrived, a String. Not a servlet name: a forward keeps the method, and an error page that answers differently for a HEAD can read it here.
      See Also:
    • ERROR_EXCEPTION

      public static final String ERROR_EXCEPTION
      The exception that escaped the handler, a Throwable; absent when the error is not an exception (a path nothing serves, a body the router could not decode).
      See Also: