Interface Presentable


  • public interface Presentable

    Created by Jeff Gaynor
    on 10/20/11 at 2:02 PM

    A filter for servlets that display something.

    Servlets that present something to a user (e.g. those serving up JSP) implement this interface. The contract is then that in the main doGet or doPost methods, prepare is invoked before the start of every call and present at the very end. Generally servlets should not touch the response output stream before handing it off, though be sure to consult any documentation.

    • Method Detail

      • prepare

        void prepare​(PresentableState state)
              throws Throwable
        This is invoked before the main processing for this servlet. The aim is that all presentation-specific processing will be done here, e.g. setting form values before displaying them.
        Parameters:
        state -
        Throws:
        Throwable
      • present

        void present​(PresentableState state)
              throws Throwable
        This is invoked after the main processing for the servlet. This contains the code that actually displays the results of processing to the user.
        Parameters:
        state -
        Throws:
        Throwable
      • handleError

        void handleError​(PresentableState state,
                         Throwable t)
                  throws IOException,
                         javax.servlet.ServletException
        Handle and error. Generally this means show an error page to be displayed when there is a problem. If this is due to an exception, the exception handler will pass along the exception as an attribute named exception in the request.
        Throws:
        IOException
        javax.servlet.ServletException