Class Utils


  • public class Utils
    extends Object
    Util class to implement simple Http request/response transactions.
    • Constructor Detail

      • Utils

        public Utils()
    • Method Detail

      • redirect

        public static void redirect​(jakarta.servlet.http.HttpServletResponse hres,
                                    PrintWriter out,
                                    String redirectUrl,
                                    Map pmap,
                                    String action)
                             throws Exception
        Redirects to redirectUrl as a GET or a POST based on action parameter provided. in case of POST all params need to be specified in pmap parameter.
        Parameters:
        hres - HttpSevletResponse to be used for the redirect
        out - the print writer for writing out presentation
        redirectUrl - URL to redirect to.
        pmap - http parameters to be sent as part of the redirect
        action - http action to be executed : GET or POST
        Throws:
        Exception
      • queryStringFromRequest

        public static String queryStringFromRequest​(jakarta.servlet.http.HttpServletRequest request)
        Generates a query string from the parameters in the request.
        Parameters:
        request - http request to pick params from.
        Returns:
        query string
      • queryStringFromMap

        public static String queryStringFromMap​(Map pmap)
        Generates a query string from the a Map.
        Parameters:
        pmap - params to be added to the query string.
        Returns:
        query string
      • formFromMap

        public static String formFromMap​(String redirectUrl,
                                         Map pmap,
                                         boolean addAutoSubmit)
        Generates a html hidden form to acccomplish a auto POST from the browser Form is assigned an id=saeform
        Parameters:
        redirectUrl - URL to post teh form to.
        pmap - parameters to be sent in the POST
        addAutoSubmit - adds html and javascript to autosubmit form
        Returns:
        html code