Class JspHelper


  • public class JspHelper
    extends java.lang.Object
    Helper JavaBean for JSPs, because JSTL 1.1/EL 2.0 is too dumb to do what I need (call methods with parameters), or I am too dumb to use it correctly. :)
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String escapeXml​(java.lang.Object obj)
      Escapes XML special characters in the given object's string representation.
      static java.lang.String escapeXml​(java.lang.String buffer)
      Performs the following substring replacements (to facilitate output to XML/HTML pages): & -> &amp; < -> &lt; > -> &gt; " -> &#034; ' -> &#039;
      static java.lang.String formatNumber​(long number)
      Formats a long number using the default locale's number format.
      static java.lang.String getDisplayCreationTimeForSession​(Session in_session)
      Returns the formatted creation time for the given session.
      static java.lang.String getDisplayInactiveTimeForSession​(Session in_session)
      Returns the formatted inactive time for the given session.
      static java.lang.String getDisplayLastAccessedTimeForSession​(Session in_session)
      Returns the formatted last accessed time for the given session.
      static java.lang.String getDisplayTTLForSession​(Session in_session)
      Returns the formatted time-to-live for the given session.
      static java.lang.String getDisplayUsedTimeForSession​(Session in_session)
      Returns the formatted total used time for the given session.
      static java.lang.String guessDisplayLocaleFromSession​(Session in_session)
      Try to get user locale from the session, if possible.
      static java.lang.String guessDisplayUserFromSession​(Session in_session)
      Try to get username from the session, if possible.
      static java.lang.String secondsToTimeString​(long in_seconds)
      Converts a number of seconds to a formatted time string in HH:mm:ss format.
      • Methods inherited from class java.lang.Object

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

      • guessDisplayLocaleFromSession

        public static java.lang.String guessDisplayLocaleFromSession​(Session in_session)
        Try to get user locale from the session, if possible.

        IMPLEMENTATION NOTE: this method has explicit support for Tapestry 3 and Struts 1.x

        Parameters:
        in_session - Session from which the locale should be guessed
        Returns:
        String
      • guessDisplayUserFromSession

        public static java.lang.String guessDisplayUserFromSession​(Session in_session)
        Try to get username from the session, if possible.
        Parameters:
        in_session - The Servlet session
        Returns:
        the username
      • getDisplayCreationTimeForSession

        public static java.lang.String getDisplayCreationTimeForSession​(Session in_session)
        Returns the formatted creation time for the given session.
        Parameters:
        in_session - the session
        Returns:
        the formatted creation time, or empty string if invalid
      • getDisplayLastAccessedTimeForSession

        public static java.lang.String getDisplayLastAccessedTimeForSession​(Session in_session)
        Returns the formatted last accessed time for the given session.
        Parameters:
        in_session - the session
        Returns:
        the formatted last accessed time, or empty string if invalid
      • getDisplayUsedTimeForSession

        public static java.lang.String getDisplayUsedTimeForSession​(Session in_session)
        Returns the formatted total used time for the given session.
        Parameters:
        in_session - the session
        Returns:
        the formatted used time string
      • getDisplayTTLForSession

        public static java.lang.String getDisplayTTLForSession​(Session in_session)
        Returns the formatted time-to-live for the given session.
        Parameters:
        in_session - the session
        Returns:
        the formatted TTL string
      • getDisplayInactiveTimeForSession

        public static java.lang.String getDisplayInactiveTimeForSession​(Session in_session)
        Returns the formatted inactive time for the given session.
        Parameters:
        in_session - the session
        Returns:
        the formatted inactive time string
      • secondsToTimeString

        public static java.lang.String secondsToTimeString​(long in_seconds)
        Converts a number of seconds to a formatted time string in HH:mm:ss format.
        Parameters:
        in_seconds - the number of seconds
        Returns:
        the formatted time string
      • escapeXml

        public static java.lang.String escapeXml​(java.lang.Object obj)
        Escapes XML special characters in the given object's string representation.
        Parameters:
        obj - the object to escape
        Returns:
        the escaped XML string
      • escapeXml

        public static java.lang.String escapeXml​(java.lang.String buffer)
        Performs the following substring replacements (to facilitate output to XML/HTML pages):
        • & -> &amp;
        • < -> &lt;
        • > -> &gt;
        • " -> &#034;
        • ' -> &#039;
        Parameters:
        buffer - The XML to escape
        Returns:
        the escaped XML
      • formatNumber

        public static java.lang.String formatNumber​(long number)
        Formats a long number using the default locale's number format.
        Parameters:
        number - the number to format
        Returns:
        the formatted number string