Enabling GZIP compression on the HTTPBC or a suggested alternative approach
Hi,
I posted this on the openusb-users group, but I haven't come up with a good solution yet.
Any takers?
Thanks,
Rob
http://openesb-users.794670.n2.nabble.com/gzip-compression-support-in-HTTP-BC-tp5366301.html
Does anybody know whether the HTTP BC shares all of the same features that the Glassfish HTTP listener supports such as gzip compression? If so, where are those parameters specified for the HTTP BC? (Compression of the XML can of course make a tremendous bandwidth savings for the typical XML passed around via SOAP.)
Please see:
http://docs.sun.com/app/docs/doc/820-4338/abhco?a=view
compression - on
Specifies use of HTTP/1.1 GZIP compression to save server bandwidth. Allowed values are:
off Disables compression.
on Compresses data.
force Forces data compression in all cases.
positive integer Specifies the minimum amount of data required before the output is compressed.
If the content-length is not known, the output is compressed only if compression is set to on or force.
compressableMimeType text/html,text/xml,text/plain
Specifies a comma-separated list of MIME types for which HTTP compression is used.
If there isn't a way to configure the HTTPBC, What would be the best way to enable a gzip compression of the XML for the HTTPBC or JBI framework in general?
My first approach might be to just have a Glassfish HTTP-Listener based WebService delegate to the HTTPBC or more directly to the JBI SE components if possible. Maybe a filter on the HTTPBC to gzip the payload? Are there any plans to refactor HTTPBC to use the Glassfish HTTP Listener code, it appears to have more capability and options?
Rob
I tried it did not work.
Below are the steps which I did:
Test2: Table level compression test
===================================
CREATE TABLE SCOTT.TEST_PMT_TAB_COMP
PMT_ID INTEGER NOT NULL,
PMT_AGCY_NBR CHAR(7 BYTE),
PMT_SBAGCY_NBR CHAR(7 BYTE),
PMT_PAY_DT DATE,
PMT_POL_NBR CHAR(14 BYTE),
PMT_POL_SEQ_NBR CHAR(2 BYTE),
PMT_PRM_INSD_NM VARCHAR2(30 BYTE),
PMT_PAY_TYP_DESC VARCHAR2(20 BYTE),
PMT_PAY_AMT NUMBER(11,2),
PMT_POST_DT DATE
COMPRESS FOR ALL OPERATIONS;
inserting record from the test table:
SQL> insert into SCOTT.TEST_PMT_TAB_COMP select * from SCOTT.TEST_PMT;
5051013 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from scott.TEST_PMT_TAB_COMP;
COUNT(*)
5051013
Checking size:
SQL> select bytes/1024/1024, segment_name, owner, segment_type, tablespace_name from dba_segments where segment_name='TEST_PMT_TAB_COMP';
BYTES/1024/1024 SEGMENT_NAME OWNER SEGMENT_TYPE TABLESPACE_NAME
776 TEST_PMT_TAB_COMP SCOTT TABLE USERS_DATA01
SQL> select owner, table_name, COMPRESSION, COMPRESS_FOR from dba_tables where table_name='TEST_PMT_TAB_COMP';
OWNER TABLE_NAME COMPRESS COMPRESS_FOR
SCOTT TEST_PMT_TAB_COMP ENABLED OLTP
Now it is occupying more size.
Similar Messages
-
How Do I enable gzip compression on Sun One Web Server 6.0
How Do I enable gzip compression on Sun One Web Server 6.0
Hi,
Sun ONE webserver 6.0 is over 5 years old and is reaching end of support life. Please consider upgrading to webserver 6.1sp5 which is free:
http://www.sun.com/download/products.xml?id=434aec1d
or else the preview version of WebServer 7.0 (also free)):
http://www.sun.com/download/products.xml?id=446518d5
For webserver 6.1, the docs for setting up compression are at:
http://docs.sun.com/source/819-0130/agcontnt.html#wp1019634
and
http://docs.sun.com/source/817-6252/npgnsapi.html
Hope this helps -
Enable Gzip compression for .CSS and .JS files
This may be posted on the wrong forum, but I did not know a better place. My excuses if it should have been posted elsewhere.
Situation:
Several webpages are slow to load. Well, they are pretty large. Google Webmaster Tools suggests to GZIP several .CSS and .JS files to save up to 164 KB per page and my guess is that will make the loading a lot faster. I looked around the hosting site for tools to enable GZIP compression, but did not find them.
Question:
How can I enable GZIP compression on my pages and how do I do that? Does it pay to extend GZIP to the .HTML pages as well or is that not possible?
Reference: PPBM5 Benchmark and Holländische Poffertjes
The hosting company is 1and1.comBarry, go to: http://ppbm5.com/Benchmark5.html and use one of the buttons for the performance charts.
There are 5 HTML pages, each around 740 KB. Compressing them would make a huge difference I think, but also the 164 KB that Google mentions.
These pages contain the same functionality, but different content. -
I can't activate spell checker because there are no misspelled words underlined, when I know that there are.
To enable underlining of incorrectly spelt words as you type:
'Tools' > 'Options' > 'Composition' > 'Spelling' tab
or
'Menu icon' > 'Options' > 'Options' > 'Composition' > 'Spelling' tab
select : 'Enable spell check as you type'
click on OK
However, you do not have to have this enabled in order to use Spellcheck.
Click on 'Spelling' in the toolbar, it will open a small window offering potential spelling corrections for mispelt words. -
Is it possible to enable Web Cache gzip compression for 9iAS Disco Viewer?
Hi,
Sorry for repeating this question. But it's very urgent and we don't have any idea yet how to solve / work around it:
To keep it short: Is it possible to use Web Cache gzip compression for pages rendered by 9iAS Discoverer Viewer???
Our scenario: We have some Discoverer Worksheets which we want to access by ISDN dial in (64 kbit/sec). An average page needs 2 minutes only for sending the html/javascript output rendered by Disco Viewer to the client browser.
To speed up the response time when users use this slow connection, we want to activate Web Cache gzip compression.
The problem: But even when we enable Web Cache for Discoverer (configuration.xml and Web Cache rules), Web Cache doesn't compress pages generated by Discoverer Viewer. We found out that the generated responses contain the "content-disposition" HTTP-Header entry. Are we correct that this is the reason why there is no gzip compression? AND DOES ANYONE KNOW A WORKAROUND (p.e. configure Disco not to add the content-disposition http header)???
Best regards,
Matthias SchererMatthias,
Have you raised this as a TAR with Oracle Support? If you've got a specific question, and you need a definitive answer, raising a TAR is the best way to proceed.
regards
Mark Rittman -
Is it possible to enable Web Cache gzip compression with 9iAS Disco Viewer?
Hi,
Sorry for repeating this question. But it's very urgent and we don't have any idea yet how to solve / work around it:
To keep it short: Is it possible to use Web Cache gzip compression for pages rendered by 9iAS Discoverer Viewer???
Our scenario: We have some Discoverer Worksheets which we want to access by ISDN dial in (64 kbit/sec). An average page needs 2 minutes only for sending the html/javascript output rendered by Disco Viewer to the client browser.
To speed up the response time when users use this slow connection, we want to activate Web Cache gzip compression.
The problem: But even when we enable Web Cache for Discoverer (configuration.xml and Web Cache rules), Web Cache doesn't compress pages generated by Discoverer Viewer. We found out that the generated responses contain the "content-disposition" HTTP-Header entry. Are we correct that this is the reason why there is no gzip compression? AND DOES ANYONE KNOW A WORKAROUND (p.e. configure Disco not to add the content-disposition http header)???
Best regards,
Matthias SchererWhen you set the caching rules, you can also specify whether or not you want the pages to be compressed. Web Cache compresses html pages and relies on the accept-encoding: gzip from the client header to determine whether or not to send the content compressed.
-
What are the required settings to enable HTTP Compression?
I am running into download speed issues with some of my clients. I am looking for ways to improve download response without having to rewrite my system(s).
On the server side, I am using CF 8.01 on a W2003 system. I have enable HTTP Compression for the web site in IIS 6.0 for both static and dynamic files.
On the client side where I am doing my testing, I am using IE 8.0 on a W7 professional system. In I.E., I have enabled HTTP 1.1 under advanced options and am using Automatic mode as the download methodology for Temporary Files.
It is my understanding that there is nothing that I have to do to CF to enable HTTP Compression.
It does not appear to work because the downloaded cfm files (5717 and 694389) are the same size regardless of these setting. In addition, I am using HttpWatch to determine all of the time and size parameters for each request. HttpWatch tells me in the summary that there are no HTTP Compression savings; i.e., HTTP Compression saving: 0 bytes. Based upon some of the info I've read on the web, I would have expected 50% to 75% savings since the two files being downloaded are both dynamic text files. All of the graphics, javascript, css files are cached so they do not figure into the equation.
Is there something else beyond the IIS and IE settings that needs to be done to implement HTTP Compresssion???
Thanks in advance for your suggestions/help.
LenAdam,
I have read the references and may now be confused, but it seems to me that just doing the standard IIS Manager setup, which is what I've done, will not compress CFM files since the only things that are compressed under dynamic files are exe, dll and asp.
One would think that CF should have added CFM to the list of compressed dynamic files when it was installed as it does with default.cfm, but maybe I'm expecting too much.
If I am correct about this, then it would seem that I'm going to have to customize the compression setup as described in this quote from the reference,
"Specify additional file types to compress. Edit the ... HcScriptFileExtensions metabase property (for dynamic files) to apply compression to additional file types."
Am I misunderstanding this document???
Len -
WebService Client - how to enable HTTP Compression
Hi
I have written a simple WebService Client. The WebService expects that the WebService clients enable HTTP compression. This is the exact text from the docs:-
""1. Client should be HTTP Compression enabled
HTTP Compression had been made mandatory for API�s. Thus API�s client should
include �Accept-Encoding: zip� header as part of request and should be able to
handle compressed data. Please note that system will send an error message if client
are not http compression enabled saying client should be compression enabled."
I do not know how to enable HTTP compression in the WebService Client. The method called is "GetInstantaneousFlowData". It accepts no arguments and returns xsd:datetime.
The wsdl can be found at:-
http://energywatch.natgrid.co.uk/EDP-PublicUI/PublicPI/InstantaneousFlowWebService.asmx?WSDL
Can someone please help :-
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Service;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
import java.util.Calendar;
public class TestNGPubTime4 {
public static void main(String[] args) throws Exception {
// Setup the global JAX-RPC service factory
System.setProperty( "javax.xml.rpc.ServiceFactory", "weblogic.webservice.core.rpc.ServiceFactoryImpl");
// create service factory
ServiceFactory factory = ServiceFactory.newInstance();
// define qnames
String targetNamespace = "http://www.NationalGrid.com/EDP/BusinessEntities/Public/";
QName serviceName = new QName(targetNamespace, "InstantaneousFlowWebService");
QName portName = new QName(targetNamespace, "InstantaneousFlowWebServiceSoap");
QName operationName = new QName("http://www.NationalGrid.com/EDP/UI/GetInstantaneousFlowData",
"GetLatestPublicationTime");
// create service
Service service = factory.createService(serviceName);
// create call
Call call = service.createCall();
// set port and operation name
call.setPortTypeName(portName);
call.setOperationName(operationName); // add parameters
call.setProperty(Call.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
call.setProperty(Call.SOAPACTION_URI_PROPERTY, "http://www.NationalGrid.com/EDP/UI/GetInstantaneousFlowData");
// call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, "http://schemas.xmlsoap.org/soap/encoding/");
call.setReturnType(new QName( "http://www.w3.org/2001/XMLSchema","datetime") );
// set end point address : soap address location
call.setTargetEndpointAddress("http://energywatch.natgrid.co.uk/EDP-PublicUI/PublicPI/InstantaneousFlowWebService.asmx");
// invoke the remote web service
Calendar result = (Calendar) call.invoke(new Object[] {});
System.out.println("result=" + result);
}Rishika,
Thanks for your reply.
Could I get clariffication on some more thing?
I am using Axis 1.4 version. And I am able to implement the gzip while doing the following steps.
1) Change the pivote value to CommonsHTTpSender.
<transport name="http" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender"/>
2) public class RetreiveReservationsSOAPBindingStubLocal extends RetreiveReservationsSOAPBindingStub.
I Override the method to support GZIP.
org.apache.axis.client.Call _call = super.createCall();
call.setOperation(operations[0]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("retreiveReservations");
_call.setEncodingStyle(null);
call.setProperty(org.apache.axis.client.Call.SENDTYPE_ATTR, Boolean.FALSE);
call.setProperty(org.apache.axis.AxisEngine.PROPDOMULTIREFS, Boolean.FALSE);
call.setProperty(HTTPConstants.MCACCEPT_GZIP, Boolean.TRUE);
call.setProperty(HTTPConstants.MCGZIP_REQUEST, Boolean.TRUE);
call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("", "retreiveReservations"));
super.setRequestHeaders(_call);
super.setAttachments(_call);
Object resp = call.invoke(new Object[] {retreiveReservationsRequest});
I am able to send and receive the request and response in gzip encoded format.
Now my clarrification is,
Is it possible to set the piote value to CommonsHTTPSender for the transport http through my code?
How could I set the values from code?
Reason is, I don't want to manually edit the axis 1.4's client-config.wsdd
Since this is very critical thing, please please help me.
Thanks in advance.
Regards,
Nishad Ponery -
Gzip compression coldfusion MX 7 !?
Is it possible to automatically enable gzip compression for all pages ? I really have no idea where to start.
using this will reduce your whitespace.
<CFPROCESSINGDIRECTIVE SUPPRESSWHITESPACE="true">
*Entire page*
</CFPROCESSINGDIRECTIVE>
Remove all inline style and script content, placing it in appropriate files and using the correct tags to link them in. dont forget the </script> tags, <script> cannot self close.
CSS and JS files will be cached, so theres a real advantage there. Also, let google host jQuery or what ever other library you're using. Google it for more.
Investigate your page caching (on the client side) options by using meta tags,
Remove/replace table layout designs to further reduce the weight of your markup.
Change your provider or get a low end private hosted box that you can RDP into and work over as you see fit.
D. -
Using native IIS 6.0 Gzip Compression in front of WLS 8.1 SP5
(IIS 6.0 => ISAPI proxy(/*) => WLS 8.1 SP5 )
Instead of usign a servlet filter and Gzip compression inside the, I would like to test the IIS 6.0 Gzip compression. I want to do this because the IIS server farm is severley underutilized in CPU and seems like the best use of that resource.
It is easy to config this in IIS 6.0. However, I can get IIS served static pages back compressed, but requests proxied to WLS return uncompressed, even though I have configured DLL calls to be zipped inide IIS.
The question is: has anyone done this and if so, what is the config.I am trying to solve the same issue. This is what I've discovered so far. I have been able to get page compression to work with IIS 4.0 and 5.0 using the iisproxy plugin. The trick was to add both "jsp" and "wlforward" extensions to the script file list to compress dynamic files.
IIS 6.0 changed the compression module from an ISAPI plugin to internal code. The configurations look the same, but I am not able to get JSPs to be compressed. I can compress static files, I can compress ASP files so I know I have compression working and I know that I have dynamic file compression working.
This is a great article on configuring compression in IIS, it should get you started in the right direction. I know it's from a .Net site, but the fundamentals are the same and it's very well written.
http://dotnetjunkies.com/Article/16267D49-4C6E-4063-AB12-853761D31E66.dcik
I am now trying to figure out how to get IIS 6.0 dynamic page compression to work with the iisproxy plugin. Any ideas? -
HTTP Headers - enabling caching and compression with the portal?
Has anyone configured their web server (IIS or Apache) or use a commercial product to flawlessly cache and compress all content generated by the portal?
Compression and caching is critical for making our portal based applictions work for overseas users. It should be doable, just taking advantage of standard HTTP protocols, but implementing this a complex system like the portal is tricky, we seem to be generating different values in the HTTP Headers for the same types of files (such as CSS).
We are running Apache so can't take advantage of the built in compression capabilities of the .net portal. We are running the java vervion. 6.1 mp1, sql server 2000 (portal, search, collab, publisher, studio, analytics, custom .net and java portlets on remote server).
Basically our strategy is to compress all outgoing static and dynamic text content (html, CSS, javascript), and to cache all static files (CSS, javascript, images) for 6 months to a year depending on file type.
Here are some links on the subjects of caching and compression that I have compiled:
Caching & Compression info and tools
http://www.webreference.com/internet/software/servers/http/compression/
http://www.ibm.com/developerworks/web/library/wa-httpcomp/
http://www.mnot.net/cache_docs/
http://www.codeproject.com/aspnet/HttpCompressionQnD.asp?df=100&forumid=322472&exp=0&select=1722189#xx1722189xx
http://en.wikipedia.org/wiki/Http_compression
http://perl.apache.org/docs/tutorials/client/compression/compression.html
https://secure.xcache.com/Page.aspx?c=60&p=590
http://www.codinghorror.com/blog/archives/000807.html
http://www.howtoforge.com/apache2_mod_deflate
http://www.ircache.net/cgi-bin/cacheability.py
http://betterexplained.com/articles/how-to-optimize-your-site-with-http-caching/
http://betterexplained.com/articles/speed-up-your-javascript-load-time/
http://betterexplained.com/articles/speed-up-your-javascript-load-time/
http://www.rubyrobot.org/article/5-tips-for-faster-loading-web-sites
http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/
http://www.gidnetwork.com/tools/gzip-test.php
http://www.pipeboost.com/
http://www.schroepl.net/cgi-bin/http_trace.pl
http://leknor.com/code/gziped.php?url=http%3A%2F%2Fwww.google.com
http://www.port80software.com/surveys/top1000compression/
http://www.rexswain.com/httpview.html
http://www.15seconds.com/issue/020314.htm
http://www.devwebpro.com/devwebpro-39-20041117DevelopingYourSiteforPerformanceCompressionandOtherServerSideEnhancements.html
http://www.webpronews.com/topnews/2004/11/17/developing-your-site-for-performance-optimal-cache-control
http://www.sitepoint.com/print/effective-website-acceleration
http://nazish.blog.com/1007523/
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/IETechCol/dnwebgen/IE_Fiddler2.asp?frame=true
http://www.fiddlertool.com/fiddler/version.asp
http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
http://www.web-caching.com/cacheability.html
http://www.edginet.org/techie/website/http.html
http://www.cmlenz.net/blog/2005/05/on_http_lastmod.html
http://www.websiteoptimization.com/speed/tweak/cache/
http://www.webperformance.org/caching//caching_for_performance.html
http://betterexplained.com/articles/how-to-debug-web-applications-with-firefox/
Edited by tkoenings at 06/18/2007 6:26 AMHi Scott,
Does Weblogic platform 8.1 supports netscape? We have developed a portal which
works perfectly on IE but it dies in netscape. Is netUI tags not supported in
Netscape?
Pls reply
manju
Scott Dunbar <[email protected]> wrote:
From a pure HTML perspective Portal does it's rendering with nested
tables.
Netscape 4.x and below have terrible performance with nested tables.
The
problem is not the Portal server but rather Netscape on the client machine.
If IE and/or a recent version of Netscape/Mozilla is not possible then
there are
really only two options:
1) Faster client hardware - not likely to be an acceptable solution.
2) Minimize the number of portlets and the complexity within the portlets.
Neither of these solutions are a great answer, but the 4.7 series of
Netscape is
getting pretty old. Having said that, we've got customers who want to
continue
to use IE 4 :)
Again, though, this problem is, I'm afraid out of our hands. It is the
client
rendering time that is the issue.
cg wrote:
Does anyone know of any known reasons why the 7.0 (did it also with4.0) portal
pages can take up to almost 30 seconds to load in Netscape 4.7? I knowit is a
very generic question but our customer still uses 4.7 and will notuse the portal
b/c it takes so long to load some of the webapps. What the pages willdo when
loading is that the headers will come up and when it gets to the bodyof the page
it seems to stall and then comes up all of a sudden. For some of thepages it
takes 6 seconds and for others it takes about 24-27 seconds.
We have suggested using IE only but that is not an option with allof the customers
and getting a newer version of Netscape is also out of the question.
Any suggestions would be greatly appreciated.--
scott dunbar
bea systems, inc.
boulder, co, usa -
GZip Compression filter for Weblogic 11g.
Hi,
I are using WLS 11g for our application development. I have identified and used PlanetJ gzip compression filter and its working fine in our dev environment. I am looking for alternate commercial supported gzip filter for wls.
Can anybody suggest a commercial gzip filter? Or PlanetJ gzip filter is a good one?. We excepect the application to scale up to 150 users and the filter selected should not be an issue for this. Also is there any official oracle/wls supported gzip filters available?
Any help on this is highly appreciated.
regards
jossy.Thank you for the answer. But currently we are looking to including filter at WLS as the suggestion by you will involve lot of architectural changes. Could you please answer if any weblogic/oracle supported filter is avaialble for enabling compression at WLS.
thanks and regards
jossy. -
Discoverer Servlet with Web Cache gzip Compression
Hi,
we have some Discoverer Worksheets which we want to access by ISDN dial in (64 kbit/sec). To speed up the response time when users use this slow connection, we want to activate Web Cache gzip compression.
But even when we enable Web Cache for Discoverer (configuration.xml), Web Cache don't compress pages generated by Discoverer Viewer. We found out that the generated responses contain the "content-disposition" HTTP-Header entry. Are we correct that this is the reason why there is no gzip compression? AND DOES ANYONE KNOW A WORKAROUND???
Best regards,
Matthias SchererWhen you set the caching rules, you can also specify whether or not you want the pages to be compressed. Web Cache compresses html pages and relies on the accept-encoding: gzip from the client header to determine whether or not to send the content compressed.
-
GZip Compression (Yes this old chestnut Again)
I have a client who requires this to work in .NET 4 Client Profile so no 4.5 compression improvements for me. All I need is 2 functions one to compress and one to decompress
both of which take in and return unicode strings. I have spent weeks nay months searching tweaking writing etc. to no avail, I have looked at all the existing snippets I could find but they
all either take in or return a Byte() or Stream or something else and when I tweak them to take/return a string they don't work. What I have so far (a snippet found online tweaked) is:
Public Shared Function Decompress(bytesToDecompress As String) As String
Using stream = New IO.Compression.GZipStream(New IO.MemoryStream(System.Text.Encoding.Unicode.GetBytes(bytesToDecompress)), IO.Compression.CompressionMode.Decompress)
Const size As Integer = 4096
Dim buffer = New Byte(size - 1) {}
Using memoryStream = New IO.MemoryStream()
Dim count As Integer
Do
count = stream.Read(buffer, 0, size)
If count > 0 Then
memoryStream.Write(buffer, 0, count)
End If
Loop While count > 0
Return System.Text.Encoding.Unicode.GetString(memoryStream.ToArray())
End Using
End Using
End Function
Public Shared Function Compress(Input As String) As String
Dim bytes() As Byte = System.Text.Encoding.Unicode.GetBytes(Input)
Using stream = New IO.MemoryStream()
Using zipStream = New IO.Compression.GZipStream(stream, IO.Compression.CompressionMode.Compress)
zipStream.Write(bytes, 0, bytes.Length)
Return System.Text.Encoding.Unicode.GetString(stream.ToArray())
End Using
End Using
End Function
However the problem is if you run the following you get nothing out.
Decompress(Compress("Test String"))
Please help me; I know this has been covered to death elsewhere but I am missing something when tweaking I am sure it's something very simple but it is causing me great stress! Many Many Thanks Indeed!I have now found a workaround which may be useful to others so I am posting it here, it doesn't do exactly what was described above which would be ideal but here is the code:
Private Sub WriteCompressed(ByVal Path As String, Data As String)
Using WriteFileStream As IO.FileStream = IO.File.Create(Path)
Using DataStream As New IO.MemoryStream(System.Text.Encoding.Unicode.GetBytes(Data))
Using Compressor As IO.Compression.DeflateStream = New IO.Compression.DeflateStream(WriteFileStream, IO.Compression.CompressionMode.Compress)
DataStream.CopyTo(Compressor)
End Using
End Using
End Using
End Sub
Private Function ReadCompressed(ByVal Path As String) As String
Using ReadFileStream As IO.FileStream = System.IO.File.OpenRead(Path)
Using DataStream As New IO.MemoryStream
Using Decompressor As IO.Compression.DeflateStream = New IO.Compression.DeflateStream(ReadFileStream, IO.Compression.CompressionMode.Decompress)
Decompressor.CopyTo(DataStream)
Return System.Text.Encoding.Unicode.GetString(DataStream.ToArray)
End Using
End Using
End Using
End Function
Many thanks indeed to everyone who helped and any more input is still welcome. Thanks again!
That's great. You should propose your post as the answer to end the thread.
I just finished with a different method. However I will guess the real issue is that strings can not contain various binary values such as Nulls, Delete, Bell, Backspace, etc (as you can see zeros in RTB2 in the image below which are null
values).
I forgot to add that during testing I was receiving errors because compressed data written to a string then read from a string into bytes and decompressed would return errors during the decompressing that the data did not contain a valid GZip header. Therefore
when GZip compresses it uses some format for the compressed data that is known to Gzip. Otherwise it would not have a header in the compressed data.
You can see what binary values (Decimal) would be in a string at this link
Ascii Table.
Therefore I used the code below to get a string from a RichTextBox1 to a byte array. That is compressed and output to a byte array.
The information in the "compressed" byte array is then converted byte by byte to the bytes value in RichTextBox2 with each value separated by a comma.
To decompress the string in RichTextBox2 that text is split into a string array on a comma. Then each item is converted to a byte into a List(Of Byte). The List(Of Byte).ToArray is then decompressed back into a byte array and that byte array is converted
to a string in RichTextBox3.
I suspect the actual compressed byte array could be written to a binary file using the
BinaryWriter Class if the original strings were supposed to be compressed and attached as files for transfer somewhere.
Option Strict On
Imports System.IO
Imports System.IO.Compression
Imports System.Text
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Location = New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (Me.Width / 2)), CInt((Screen.PrimaryScreen.WorkingArea.Height / 2) - (Me.Height / 2)))
RichTextBox1.Text = My.Computer.FileSystem.ReadAllText("C:\Users\John\Desktop\Northwind Database.Txt")
Label1.Text = "Waiting"
Label2.Text = "Waiting"
Label3.Text = "Waiting"
Label4.Text = "Waiting"
Button2.Enabled = False
End Sub
Dim BytesCompressed() As Byte
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
RichTextBox2.Clear()
RichTextBox3.Clear()
Label1.Text = "Waiting"
Label2.Text = "Waiting"
Label3.Text = "Waiting"
Label4.Text = "Waiting"
If RichTextBox1.Text <> "" Then
Dim uniEncoding As New UnicodeEncoding()
BytesCompressed = Compress(uniEncoding.GetBytes(RichTextBox1.Text))
Label1.Text = RichTextBox1.Text.Count.ToString
Label2.Text = BytesCompressed.Count.ToString
For Each Item In BytesCompressed
RichTextBox2.AppendText(CStr(CInt(Item)) & ",")
Next
RichTextBox2.Text = RichTextBox2.Text.Remove(RichTextBox2.Text.Count - 1, 1)
End If
Button2.Enabled = True
End Sub
Private Shared Function Compress(data As Byte()) As Byte()
Using compressedStream = New MemoryStream()
Using zipStream = New GZipStream(compressedStream, CompressionMode.Compress)
zipStream.Write(data, 0, data.Length)
zipStream.Close()
Return compressedStream.ToArray()
End Using
End Using
End Function
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Button2.Enabled = False
Dim RTB2Split() As String = RichTextBox2.Text.Split(","c)
Dim BytesToUse As New List(Of Byte)
For Each Item In RTB2Split
BytesToUse.Add(CByte(Item))
Next
Label3.Text = BytesToUse.Count.ToString
Dim uniEncoding As New UnicodeEncoding()
RichTextBox3.Text = uniEncoding.GetString(Decompress(BytesToUse.ToArray))
Label4.Text = RichTextBox3.Text.Count.ToString
End Sub
Private Shared Function Decompress(data As Byte()) As Byte()
Using compressedStream = New MemoryStream(data)
Using zipStream = New GZipStream(compressedStream, CompressionMode.Decompress)
Using resultStream = New MemoryStream()
zipStream.CopyTo(resultStream)
Return resultStream.ToArray()
End Using
End Using
End Using
End Function
End Class
La vida loca -
GZIP Compression Issue in Weblogic 8.1
Has anyone experienced issues with gzip compression filtering in 8.1?
After about 2 months of dev. and testing with the filter, a bug has been found
in our portal, and I have traced it back to the filter that I downloaded from
dev2dev code and utilities.
It is strange. The only time I see an issue is when a user clicks the "back button"
in the browser itself to go back to a previous page, AND then clicks a link (for
example) in a portlet that is tied to an action in a jpf for that portlet. The
error only happens for actions in a portlet that are local to that portlet (no
forwarding to other portlets or anything fancy)...just pure "local internal forwards."
If you do this, USING THE BACK BUTTON to get back to this page with the portlet,
when you click the action, you are actually taken to the page where you were when
you clicked the back button.
I have re-created this is simple portals that have no content, so I know it is
not something else I introduced.
Any ideas? Maybe it is the filter-mapping pattern I am using??? I am currently
mapping on *.portal, but this is the only situation that seems to break.For those interested, I have some updates on this subject and someone out there sent me a mail asking if I ever found anything out.
Basically, when I encountered this issue the first time, I was working on a SP2 Portal. We were having numerous small bugs like this one with SP2 that centered around the back button or refresh button. BEA gave us a "super patch" back in July or so that when applied to our SP2 project, fixed our issue. I have sense moved onto SP3, and I did not see the compression issue (so I think SP3 must have the patches correctly setup...like I would assume it would).
Maybe you are looking for
-
How to install 32 bit program with 16 bit installer on Windows 8.1 32 bit
Hi, I have installed a 32 bit program that uses a 16 bit installer on Windows XP machines. The software developer of this program is out of business. Can Windows 8.1 32 bit run a 16 bit installer? If not, any suggestions as to how I might install t
-
Best Practice to use Event trigger in 3.1
All, I am trying to start some publication upon the copy of a file.txt generated by an ETL tool Basically I would have like a cron job that would generate the txt file in a specific folder, then Business objects event server would trigger my publica
-
Cancelling an application that is in the process of downloading
I have been downloading many applications, and there are a few that are so large that require WI-FI to download. I was in a restaurant that had free wi-fi and started to download a couple of those apps. However, I had to leave before they were finish
-
Grantman - PS Elements 10 Launch
I have PS Elements 10. When I open it to start a new design it appears on the taskbar only and does not maximize to the ful screen of the monitor. This also happens when I open a previous design as well. How do I fix this?
-
Dear colleagues, where can I find documentations to the Chart designer and classes cl_gui_chart_engine and cl_igs_chart_engine ? Are there any exercise programs too ? Thanks a lot and kind regards Peter