Class ServletUtil

    • Constructor Summary

      Constructors 
      Constructor Description
      ServletUtil()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getFooter​(java.util.Locale locale, java.lang.String context)
      Create a common footer.
      java.lang.String getNavBar​(java.util.Locale locale, java.lang.String context)
      Create a common navigation header.
      java.lang.String getRailroadName​(boolean inComments)
      Get the railroad name for HTML documents.
      java.lang.String getTitle​(java.util.Locale locale, java.lang.String title)
      Return the complete title for an HTML document given the portion of the title specific to the document.
      java.util.Date setNonCachingHeaders​(javax.servlet.http.HttpServletResponse response)
      Set HTTP headers to prevent caching.
      void writeFile​(javax.servlet.http.HttpServletResponse response, java.io.File file, java.lang.String contentType)
      Write a file to the given response.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getRailroadName

        public java.lang.String getRailroadName​(boolean inComments)
        Get the railroad name for HTML documents.
        Parameters:
        inComments - Return the railroad name prepended and appended by closing and opening comment markers
        Returns:
        the Railroad name, possibly with formatting
      • getFooter

        public java.lang.String getFooter​(java.util.Locale locale,
                                          java.lang.String context)
                                   throws java.io.IOException
        Create a common footer.
        Parameters:
        locale - If a template is not available in locale, will return US English.
        context - divs included in footer template with class context-<context>-only will be shown.
        Returns:
        an HTML footer
        Throws:
        java.io.IOException - if template cannot be located
      • getNavBar

        public java.lang.String getNavBar​(java.util.Locale locale,
                                          java.lang.String context)
                                   throws java.io.IOException
        Create a common navigation header.
        Parameters:
        locale - If a template is not available in locale, will return US English.
        context - divs included in navigation bar template with class context-<context>-only will be shown.
        Returns:
        an HTML navigation bar
        Throws:
        java.io.IOException - if template cannot be located
      • setNonCachingHeaders

        public java.util.Date setNonCachingHeaders​(javax.servlet.http.HttpServletResponse response)
        Set HTTP headers to prevent caching.
        Parameters:
        response - the response to set headers in
        Returns:
        the date used for headers setting expiration and modification times
      • writeFile

        public void writeFile​(javax.servlet.http.HttpServletResponse response,
                              java.io.File file,
                              java.lang.String contentType)
                       throws java.io.IOException
        Write a file to the given response.
        Parameters:
        response - the response to write the file into
        file - file to write
        contentType - file mime content type
        Throws:
        java.io.IOException - if communications lost with client
      • getTitle

        public java.lang.String getTitle​(java.util.Locale locale,
                                         java.lang.String title)
        Return the complete title for an HTML document given the portion of the title specific to the document.
        Parameters:
        locale - The requested Locale
        title - Portion of title specific to page
        Returns:
        The complete title