Class ServletResponder

    • Constructor Detail

      • ServletResponder

        public ServletResponder()
    • Method Detail

      • respondContent

        public static void respondContent​(javax.servlet.http.HttpServletResponse resp,
                                          EMime mime,
                                          String cont)
        Setzt die Response-Header 'Content-Type' und 'Content-Length' und schreibt die übergebenen Daten in den Response. Das zu verwendende Character-Set wird über die Konstante CmnConst.DFLT_ENCODING ermittelt.
        Parameters:
        resp - - Response
        mime - - Inhaltstyp
        cont - - zu schreibende Daten
      • respondContent

        public static void respondContent​(javax.servlet.http.HttpServletResponse resp,
                                          EMime mime,
                                          String cont,
                                          String encoding)
      • respondFile

        public static void respondFile​(javax.servlet.http.HttpServletRequest req,
                                       javax.servlet.http.HttpServletResponse resp,
                                       byte[] data,
                                       String fileName,
                                       boolean inline)
      • respondFile

        public static void respondFile​(javax.servlet.http.HttpServletRequest req,
                                       javax.servlet.http.HttpServletResponse resp,
                                       byte[] data,
                                       String fileName,
                                       boolean inline,
                                       String contentType)
      • respondFile

        public static void respondFile​(javax.servlet.http.HttpServletRequest req,
                                       javax.servlet.http.HttpServletResponse resp,
                                       byte[] data,
                                       String baseName,
                                       String encoding,
                                       boolean inline,
                                       EMime mime)
      • respondFile

        public static void respondFile​(javax.servlet.http.HttpServletRequest req,
                                       javax.servlet.http.HttpServletResponse resp,
                                       byte[] data,
                                       String fileName,
                                       String encoding,
                                       boolean inline,
                                       String contentType)
      • respondFile

        public static void respondFile​(javax.servlet.http.HttpServletResponse resp,
                                       File file,
                                       boolean inline)
      • respondFile

        public static void respondFile​(javax.servlet.http.HttpServletResponse resp,
                                       File file,
                                       String fileName,
                                       boolean inline)
      • respondFile

        public static void respondFile​(javax.servlet.http.HttpServletResponse resp,
                                       File file,
                                       String fileName,
                                       String encoding,
                                       boolean inline)
      • respondStream

        public static void respondStream​(javax.servlet.http.HttpServletResponse resp,
                                         InputStream is,
                                         String fileName,
                                         boolean inline)
      • respondStream

        public static void respondStream​(javax.servlet.http.HttpServletResponse resp,
                                         InputStream is,
                                         String fileName,
                                         String encoding,
                                         boolean inline)
      • redirect

        public static void redirect​(javax.servlet.http.HttpServletResponse response,
                                    String url)
                             throws IOException
        Throws:
        IOException
      • buildTemplateHTML

        public static String buildTemplateHTML​(Locale locale,
                                               String msg)
      • respond

        public static void respond​(javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.http.HttpServletResponse response,
                                   IServletResponse responseData,
                                   Locale locale)
                            throws IOException
        Throws:
        IOException
      • writeSessionParameters

        public static void writeSessionParameters​(javax.servlet.http.HttpServletRequest request,
                                                  IServletResponse responseData)
      • writeHeader

        public static void writeHeader​(javax.servlet.http.HttpServletResponse response,
                                       IServletResponse responseData)
      • writeStatusCode

        public static void writeStatusCode​(javax.servlet.http.HttpServletResponse response,
                                           IServletResponse responseData)
      • respondHTML

        protected static void respondHTML​(javax.servlet.http.HttpServletResponse response,
                                          IServletResponse responseData)
      • respondTemplate

        protected static void respondTemplate​(javax.servlet.http.HttpServletResponse response,
                                              IServletResponse responseData,
                                              Locale locale)
      • respondJSON

        protected static void respondJSON​(javax.servlet.http.HttpServletResponse response,
                                          IServletResponse responseData)
      • respondXML

        protected static void respondXML​(javax.servlet.http.HttpServletResponse response,
                                         IServletResponse responseData)
      • respondHTML

        public static void respondHTML​(javax.servlet.http.HttpServletResponse response,
                                       String html)
      • respondPlainText

        public static void respondPlainText​(javax.servlet.http.HttpServletResponse response,
                                            String text)
      • respondJavaScript

        public static void respondJavaScript​(javax.servlet.http.HttpServletResponse response,
                                             String script)
      • respondJSON

        public static void respondJSON​(javax.servlet.http.HttpServletResponse resp,
                                       com.alibaba.fastjson.JSONObject json)
      • respondJSON

        public static void respondJSON​(javax.servlet.http.HttpServletResponse resp,
                                       com.alibaba.fastjson.JSONArray json)
      • respondJSON

        public static void respondJSON​(javax.servlet.http.HttpServletResponse resp,
                                       com.alibaba.fastjson.JSONAware json)
        Generic method to response an json
        Parameters:
        resp - the servlet response
        json - the json to resond
      • respondJSON

        public static void respondJSON​(javax.servlet.http.HttpServletResponse resp,
                                       String json)
      • respondJSONPath

        public static void respondJSONPath​(javax.servlet.http.HttpServletResponse resp,
                                           String json,
                                           String jsonPath)
        Method to response an json (or String) after evaluating an optional json path
        Parameters:
        resp - the servlet response
        json - the json to resond
        jsonPath - the (optional) json path
      • respondJSONPath

        public static void respondJSONPath​(javax.servlet.http.HttpServletResponse resp,
                                           com.alibaba.fastjson.JSONAware json,
                                           String jsonPath)
        Method to response an json (or String) after evaluating an optional json path
        Parameters:
        resp - the servlet response
        json - the json to resond
        jsonPath - the (optional) json path
      • respondXML

        public static void respondXML​(javax.servlet.http.HttpServletResponse response,
                                      String xml)
      • respondJSONMessage

        public static void respondJSONMessage​(javax.servlet.http.HttpServletRequest req,
                                              javax.servlet.http.HttpServletResponse resp,
                                              String string,
                                              boolean success)
      • respondJSONError

        public static void respondJSONError​(javax.servlet.http.HttpServletResponse resp,
                                            String msg,
                                            int sc)