com.vaadin.server.

Interface VaadinResponse

    • Method Summary

      All Methods
      Modifier and Type Method and Description
      void addCookie(Cookie cookie)

      Adds the specified cookie to the response.

      static VaadinResponse getCurrent()

      Gets the currently processed Vaadin response.

      OutputStream getOutputStream()

      Returns a OutputStream for writing binary data in the response.

      VaadinService getService()

      Gets the vaadin service for the context of this response.

      PrintWriter getWriter()

      Returns a PrintWriter object that can send character text to the client.

      void sendError(int errorCode, String message)

      Sends an error response to the client using the specified status code and clears the buffer.

      void setCacheTime(long milliseconds)

      Sets cache time in milliseconds, -1 means no cache at all.

      void setContentLength(int len)

      Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header.

      void setContentType(String contentType)

      Sets the content type of this response.

      void setDateHeader(String name, long timestamp)

      Properly formats a timestamp as a date header.

      void setHeader(String name, String value)

      Sets the value of a generic response header.

      default void setNoCacheHeaders()

      Sets all conceivable headers that might prevent a response from being stored in any caches.

      void setStatus(int statusCode)

      Sets the (http) status code for the response.

    • Method Detail

      • setDateHeader

        void setDateHeader(String name,
                           long timestamp)

        Properly formats a timestamp as a date header. If the header had already been set, the new value overwrites the previous one.

        Parameters:

        name - the name of the header

        timestamp - the number of milliseconds since epoch

        See Also:

        HttpServletResponse.setDateHeader(String, long)

      • setCacheTime

        void setCacheTime(long milliseconds)

        Sets cache time in milliseconds, -1 means no cache at all. All required headers related to caching in the response are set based on the time.

        Parameters:

        milliseconds - Cache time in milliseconds

      • sendError

        void sendError(int errorCode,
                       String message)
                throws IOException

        Sends an error response to the client using the specified status code and clears the buffer. In some configurations, this can cause a predefined error page to be displayed.

        Parameters:

        errorCode - the HTTP status code

        message - a message to accompany the error

        Throws:

        IOException - if an input or output exception occurs

        See Also:

        HttpServletResponse.sendError(int, String)

      • getService

        VaadinService getService()

        Gets the vaadin service for the context of this response.

        Returns:

        the vaadin service

        See Also:

        VaadinService

      • setContentLength

        void setContentLength(int len)

        Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header. For some portlet responses, this method sets the content-length header, for others this method does nothing.

        Parameters:

        len - an integer specifying the length of the content being returned to the client

        Since:

        7.3.8

      • setNoCacheHeaders

        default void setNoCacheHeaders()

        Sets all conceivable headers that might prevent a response from being stored in any caches.

        Since:

        8.3.2

      • getCurrent

        static VaadinResponse getCurrent()

        Gets the currently processed Vaadin response. The current response is automatically defined when the request is started. The current response can not be used in e.g. background threads because of the way server implementations reuse response instances.

        Returns:

        the current Vaadin response instance if available, otherwise null

        Since:

        8.1