Class ZipLet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
de.businesscode.bcdui.web.servlets.ZipLet
- All Implemented Interfaces:
jakarta.servlet.Servlet
,jakarta.servlet.ServletConfig
,Serializable
public class ZipLet
extends jakarta.servlet.http.HttpServlet
Servlet for compression and uncompression of XML data. To compress
an XML document you need to POST it to this servlet and to uncompress
the data you must use GET with the parameter data=xxx (where xxx stands
for the compressed data).
The servlet offers two compression modes: XML string optimization for
small XML documents and GZIP compression. It also supports two encodings:
Alphabet translation (when the input has an alphabet of at most 64 characters)
and 6 bit 64-character encoding (similar to base 64). All encodings are chosen
so that the result does not need to be escaped for being used as an HTML
GET parameter.
It is possible to determine the encoding/compression combination from the compressed document by testing the first character of the encoded data
It is possible to determine the encoding/compression combination from the compressed document by testing the first character of the encoded data
- "z" uses XML string optimization with alphabet translation.
- "x" uses XML string optimization with 6 bit encoding.
- Otherwise GZIP compression with 6 bit encoding is used.
- See Also:
-
Field Summary
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Compresses (and encodes) the string parameter.static String
A convenience method for compressing a DOM document and returning an encoded string representation.static Document
decodeAndDecompressToXML
(String compressedString) Deprecated.static Document
decodeAndDecompressToXML
(String compressedString, jakarta.servlet.http.HttpServletRequest request) Decodes and decompresses the specified string to an XML document.protected void
doGet
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Decompresses the XML document given in the "data" parameter and returns it in the response object.protected void
doPost
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Compresses the data which has been posted to this servlet.static Connection
static String
getTransformSQL
(String sql) static String
getUnpackedGuiStatus
(jakarta.servlet.http.HttpServletRequest request) void
init
(jakarta.servlet.ServletConfig config) static boolean
Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPatch, doPut, doTrace, getLastModified, isSensitiveHeader, service, service
Methods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
ZipLet
public ZipLet()
-
-
Method Details
-
init
public void init(jakarta.servlet.ServletConfig config) throws jakarta.servlet.ServletException - Specified by:
init
in interfacejakarta.servlet.Servlet
- Overrides:
init
in classjakarta.servlet.http.HttpServlet
- Throws:
jakarta.servlet.ServletException
-
doPost
protected void doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException Compresses the data which has been posted to this servlet. It will write an XML document to the response with a single root element named "data" containing a text node with the compressed and encoded data (as provided by the compress method).- Overrides:
doPost
in classjakarta.servlet.http.HttpServlet
- Throws:
jakarta.servlet.ServletException
IOException
- See Also:
-
compress(InputStream)
-
doGet
protected void doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException Decompresses the XML document given in the "data" parameter and returns it in the response object.- Overrides:
doGet
in classjakarta.servlet.http.HttpServlet
- Parameters:
request
- The request holding the "data" parameter to be decoded.response
- The response containing the (stringified) decompressed XML document.- Throws:
jakarta.servlet.ServletException
IOException
-
getUnpackedGuiStatus
- Parameters:
request
-- Returns:
- returns unpacked XML String or NULL if guiStatusGZ parameter was null or empty
-
compressAndEncode
A convenience method for compressing a DOM document and returning an encoded string representation.- Parameters:
doc
- The DOM document to be compressed.- Returns:
- An encoded String representation of the DOM document.
- Throws:
Exception
-
compress
Compresses (and encodes) the string parameter. This is a string-argument wrapper for the compress method taking an InputStream.- Parameters:
uncompressedString
- The string to be compressed.- Returns:
- A 64-character encoding of the compressed string.
- Throws:
Exception
- If the compression fails.- See Also:
-
compress(InputStream)
-
decodeAndDecompressToXML
public static Document decodeAndDecompressToXML(String compressedString, jakarta.servlet.http.HttpServletRequest request) throws Exception Decodes and decompresses the specified string to an XML document.- Parameters:
compressedString
- The stringified encoding of the compressed XML document.- Returns:
- The original XML document the compressed string has been generated from.
- Throws:
Exception
- If the decompression or the XML parsing fails.
-
decodeAndDecompressToXML
@Deprecated public static Document decodeAndDecompressToXML(String compressedString) throws Exception Deprecated.Decodes and decompresses the specified string to an XML document.- Parameters:
compressedString
- The stringified encoding of the compressed XML document.- Returns:
- The original XML document the compressed string has been generated from.
- Throws:
Exception
- If the decompression or the XML parsing fails.
-
testTinyUrlBinding
public static boolean testTinyUrlBinding() -
getControlConnection
- Throws:
Exception
-
getTransformSQL
-