com.ibm.commerce.server

Class JSPHelper

  • All Implemented Interfaces:
    ECConstants


    public class JSPHelper
    extends ServletHelper
    This is a JSP helper class to help JSP writers retrieve data from an HttpServletRequest. It will look for the parameter either from the request attribute or the request parameters. This way, the user won't need to distinguish between a JSP that is invoked through the use of a forward or a redirect.
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
    • Constructor Detail

      • JSPHelper

        public JSPHelper(javax.servlet.http.HttpServletRequest httpReq)
        This is the constructor for this class.
        Parameters:
        httpReq - An HttpServletRequest object.
    • Method Detail

      • getParameter

        public java.lang.String getParameter(java.lang.String paramName)
        This method returns a parameter from the request object as String object.
        Parameters:
        paramName - The name of the parameter.
        Returns:
        The value of the parameter.
      • getParameter

        public static java.lang.String getParameter(javax.servlet.http.HttpServletRequest req,
                                                    java.lang.String paramName)
        This method returns a parameter from the request object as String object.
        Parameters:
        req - An HttpServletRequest object.
        paramName - The name of the parameter.
        Returns:
        This method returns a java.lang.String that represents the value of the parameter.
      • getParameterValues

        public java.lang.String[] getParameterValues(java.lang.String paramName)
        This method returns a parameter from the request object as an array of String objects.
        Parameters:
        paramName - The name of the parameter.
        Returns:
        This method returns an array of java.lang.String objects that represent the values of the parameters.
      • getParameterValues

        public static java.lang.String[] getParameterValues(javax.servlet.http.HttpServletRequest req,
                                                            java.lang.String paramName)
        This method returns a parameter from the request object as an array of String objects.
        Parameters:
        req - An HttpServletRequest object.
        paramName - The name of the parameter.
        Returns:
        This method returns an array of java.lang.String objects that represent the values of the parameters.
      • getPropertyResourceBundle

        public static java.util.PropertyResourceBundle getPropertyResourceBundle(java.lang.String sfilename)
                                                                          throws java.io.IOException
        This method returns the PropertyResourceBundle object for the given JSP in the runtime default locale.
        Parameters:
        sfilename - The JSP file name.
        Returns:
        The PropertyResourceBundle for the JSP page.
        Throws:
        java.io.IOException
      • getPropertyResourceBundle

        public static java.util.PropertyResourceBundle getPropertyResourceBundle(java.lang.String sfilename,
                                                                                 javax.servlet.ServletContext servletContext,
                                                                                 javax.servlet.http.HttpServletRequest request)
                                                                          throws java.io.IOException
        This method returns the PropertyResourceBundle object for the given JSP in the runtime default locale. It will pick up property files located relative to the location of the JSP.

        Usage: java.util.ResourceBundle thisResources = com.ibm.commerce.server.JSPHelper.getPropertyResourceBundle("MyProperties", getServletContext(), request);

        Parameters:
        sfilename - The JSP file name.
        servletContext - The servlet context.
        request - An HttpServletRequest object.
        Returns:
        The PropertyResourceBundle for the JSP page.
        Throws:
        java.io.IOException
      • getPropertyResourceBundle

        public static java.util.PropertyResourceBundle getPropertyResourceBundle(java.lang.String sfilename,
                                                                                 javax.servlet.ServletContext servletContext,
                                                                                 javax.servlet.http.HttpServletRequest request,
                                                                                 java.util.Locale locale)
                                                                          throws java.io.IOException
        This method returns the PropertyResourceBundle object for the given JSP in the given locale. It will pick up property files located relative to the location of the JSP.

        Usage: java.util.ResourceBundle thisResources = com.ibm.commerce.server.JSPHelper.getPropertyResourceBundle("MyProperties", getServletContext(), request, locale);

        Parameters:
        sfilename - The JSP file name.
        servletContext - The servlet context.
        request - An HttpServletRequest object.
        locale - The locale used for the resource bundle.
        Returns:
        The PropertyResourceBundle for the JSP page.
        Throws:
        java.io.IOException
      • getPropertyResourceBundle

        public static java.util.PropertyResourceBundle getPropertyResourceBundle(javax.servlet.ServletContext servletContext,
                                                                                 javax.servlet.http.HttpServletRequest request)
                                                                          throws java.io.IOException
        This method returns the PropertyResourceBundle object for the given JSP in the runtime default locale. It will pick up property files located relative to the location of the JSP.

        Usage: java.util.ResourceBundle thisResources = com.ibm.commerce.server.JSPHelper.getPropertyResourceBundle(getServletContext(), request);

        Parameters:
        servletContext - The servlet context.
        request - An HttpServletRequest object.
        Returns:
        The PropertyResourceBundle for the JSP page.
        Throws:
        java.io.IOException
      • getPropertyResourceBundle

        public static java.util.PropertyResourceBundle getPropertyResourceBundle(javax.servlet.ServletContext servletContext,
                                                                                 javax.servlet.http.HttpServletRequest request,
                                                                                 java.util.Locale locale)
                                                                          throws java.io.IOException
        This method returns the PropertyResourceBundle object for the given JSP in the given locale. It will pick up property files located relative to the location of the JSP.

        Usage: java.util.ResourceBundle thisResources = com.ibm.commerce.server.JSPHelper.getPropertyResourceBundle(getServletContext(), request, locale);

        Parameters:
        servletContext - The servlet context.
        request - An HttpServletRequest object.
        locale - The locale used for the resource bundle.
        Returns:
        The PropertyResourceBundle for the JSP page.
        Throws:
        java.io.IOException
      • getResourceBundle

        public static java.util.ResourceBundle getResourceBundle(java.lang.String sfilename,
                                                                 javax.servlet.http.HttpServletRequest request)
        This method returns the ResourceBundle object for the given JSP in the default runtime locale. It will pick up property files located relative to the location of the JSP.
        Parameters:
        sfilename - The JSP file name.
        request - An HttpServletRequest object.
        Returns:
        The ResourceBundle for the JSP page.
      • getResourceBundle

        public static java.util.ResourceBundle getResourceBundle(java.lang.String sfilename,
                                                                 javax.servlet.http.HttpServletRequest request,
                                                                 java.util.Locale locale)
        This method returns the ResourceBundle object for the given JSP in the given locale. It will pick up property files located relative to the location of the JSP.
        Parameters:
        sfilename - The JSP file name.
        request - An HttpServletRequest object.
        locale - The locale used for the resource bundle.
        Returns:
        The ResourceBundle for the JSP page.
      • getResourceBundle

        public static java.util.ResourceBundle getResourceBundle(javax.servlet.http.HttpServletRequest request)
        This method returns the ResourceBundle object for the given JSP in the default runtime locale.
        Parameters:
        request - An HttpServletRequest object.
        Returns:
        The ResourceBundle for the JSP page.
      • getResourceBundle

        public static java.util.ResourceBundle getResourceBundle(javax.servlet.http.HttpServletRequest request,
                                                                 java.util.Locale locale)
        This method returns the ResourceBundle object for the given JSP in the given locale.
        Parameters:
        request - An HttpServletRequest object.
        locale - The locale used for the resource bundle.
        Returns:
        The ResourceBundle for the JSP page.
      • htmlTextEncoder

        public static java.lang.String htmlTextEncoder(java.lang.String iString)
        This method encodes a String for HTML.
        Parameters:
        iString - the string to encode.
        Returns:
        The encoded string. An empty string is returned if the input is null.
      • markTransactionToRollback

        public static void markTransactionToRollback()
        This method marks a transaction for rollback when an exception is caught in a JSP page.
      • rollbackTransaction

        public static void rollbackTransaction()
        This method rolls back the current transaction. This method is to be called when an error is detected in a JSP and the command associated with this JSP has to rollback.
      • rollbackTransaction

        public void rollbackTransaction(boolean flag)
        This method rolls back the current transaction and also marks the current page to be not cachable. This method is to be called when an error is detected in a JSP and the command associated with this JSP has to rollback.
        Parameters:
        flag - A boolean value; true if the page is to be cached and false otherwise.
      • rollbackTransaction

        public static void rollbackTransaction(javax.servlet.http.HttpServletRequest req,
                                               boolean flag)
        This method rolls back the current transaction and also marks the current page to be not cachable. This method is to be called when an error is detected in a JSP and the command associated with this JSP has to rollback.
        Parameters:
        req - An HttpServletRequest object.
        flag - A boolean value; true if the page is to be cached and false otherwise.
      • setCachePage

        public void setCachePage(boolean flag)
        Deprecated. This method has been replaced by setUncacheable.
        This method sets cachePage flag.
        Parameters:
        flag - A boolean value; true if the page is to be cached and false otherwise.
      • setUncacheable

        public static void setUncacheable(javax.servlet.http.HttpServletRequest req,
                                          boolean flag)
        This method sets a flag to indicate whether the output page is uncacheable.
        Parameters:
        req - An HttpServletRequest object.
        flag - A boolean value; true to disable caching the page and false otherwise.
      • setUncacheable

        public static void setUncacheable(CommandContext commandContext,
                                          boolean flag)
        This method sets a flag to indicate whether the output page is uncacheable.
        Parameters:
        commandContext - The command context.
        flag - A boolean value; true to disable caching the page and false otherwise.
      • setUncacheable

        public void setUncacheable(boolean flag)
        This method sets a flag to indicate whether the output page is uncacheable.
        Parameters:
        flag - A boolean value; true to disable caching the page and false otherwise.