Posts

Showing posts from April, 2009

Tomcat, Apache, IIS ETag Format

The ETag formatApache 1.3 and 2.x is inode-size-timestamp. Although a given file may reside in the same directory across multiple servers, and have the same file size, permissions, timestamp, etc., its inode is different from one server to the next. Tomcat simply generates a Weak ETag by concatenating the content length and the last modified time in millisecondsThe format for ETags on IIS is Filetimestamp:ChangeNumber. A ChangeNumber is a counter used to track configuration changes to IIS. It's unlikely that the ChangeNumber is the same across all IIS servers behind a web site.

Fiddler - Debug on localhost

Most of the time, web developer wants to see web traffics against localhost. If you are working with Fiddler, and by now, you should realise that Fiddler is not working with localhost or 127.0.0.1.

It is documented in fiddler website.

Some workaround is
Use machine name instead of localhost. That is http://my_machine_name/Use your local IP address. Check with ipconfig commandIf you're using Fiddler v2.1.8 or later, just use http://ipv4.fiddler to hit localhost on the IPv4 adapter, or use http://ipv6.fiddler to hit localhost on the IPv6 adapterAdd a . at localhost. That is http://localhost./myweb

Fiddler and YSlow

Image
These 2 utility are good for web developer.

YSlow - Come together with FireBug for FireFox extension and developed by Yahoo!. It provides you with Web traffic analysis as well as performance tips. Abstract from YSlow

YSlow analyzes web pages and tells you why they're slow based on the rules for high performance web sites. YSlow is a Firefox add-on integrated with the popular Firebug web development tool.

YSlow gives you: Performance report card

HTTP/HTML summary

List of components in the page

Tools including JSLint

Fiddler - Web trace tools develop for IE. It provides web debugging and analysis. The latest version claims to have FireFox Hook. Abstract from Fiddler

Fiddler is a Web Debugging Proxy which logs all HTTP(S) traffic between your computer and the Internet. Fiddler allows you to inspect all HTTP(S) traffic, set breakpoints, and "fiddle" with incoming or outgoing data. Fiddler includes a powerful event-based scripting subsystem, and can be extended using any .NET langua…

End of Analog Camera?

In the last ISC West security show in Vegas, IP-Camera is evolving very fast.

Some hits are:
Mega-pixel IP camera and Hi-Definition cameraH.264 camera streamingLow light capabilitiesBuild-in analyticsBuild-in storageThere is even a vendor who has create a NVR + Analytics within a camera.

Analog camera is almost obsolete in the show. Even Pelco is pushing hard on their new Sarix IP-Camera.

Just a though, why those some IP-Camera suppliers like to design their own H.264 stream and proprietary conntectivity? It causes inconvinence for decoding and prevent integrition opportunity...

HTTP Performance Tips - Add Expires or a Cache-Control Header

According to Yahoo HTTP best practices, adding an Expires or Cache-Control header helps to increase performance of web server. Ideally, the performance should increase as cached data are not request and transmitted over the next visit.

To archive that, you should
For static components: implement "Never expire" policy by setting far future Expires headerFor dynamic components: use an appropriate Cache-Control header to help the browser with conditional requests. The value is 48 hours.To archive this in tomcat, you have to create a Servlet Filter to intercept incoming request and set the above HTTP header in response.

I am not going to post code here as there are many existing code out there. But, if you have no idea on what to search for, those links below will help

I had tested this Expires Serlvet and it works.HTTP 1.1 Protocol ParameterHTTP 1.1 Header Fields Definition

HTTP Performance Tips - Enable GZIP Compression on Tomcat

Image
HTTP compression boost the performance of your web application. To enable HTTP compression on Tomcat, do the following

1. Locate server.xml in <tomcat install home>/conf

2. Find connector tag. Something like this






<Connector port="80" maxHttpHeaderSize="8192"

maxThreads="300" minSpareThreads="25" maxSpareThreads="100"

enableLookups="false" redirectPort="443" acceptCount="100"

connectionTimeout="120000" disableUploadTimeout="true"

URIEncoding="utf-8"/>






3. Add the following in the HTTP connector. It will enable GZIP compression for html, xml, javascript and css




compression="on"

compressionMinSize="10"

noCompressionUserAgents="gozilla, traviata"

compressableMimeType="text/html,text/xml,text/javascript,text/css"






4. Final Connector looks like




<Connector port="80" maxHttpHeaderSize="819…

Add code formatting to Blogger

Image
I understand that it is a pain to provide code block and code formatting in Blogger. Below are some tips to make your life better (hopefully, at least a bit better)

Code Container

Sometime, you will want to put your code inside a container as below






public void testCode(){

//your code here

}



To have the container, do the following

1. Go to Layout -> Edit HTML -> Edit Template



2. Search for this Code



]]></b:skin>


3. Add the following before the above code




pre{
background:#efefef;
border:1px solid #A6B0BF;
font-size:120%;
line-height:100%;
overflow:auto;
padding:10px;
color:#000000
}

pre:hover {
border:1px solid #efefef;
}

code {
font-size:120%;
text-align:left;
margin:0;
padding:0;
color: #000000;
}

.clear {
clear:both;
overflow:hidden;
}


4. Save the template

5. Now, you can add your code to the container in



<pre> code </pre>Tag Formatting


If you work with XML or Tagging with < > , you will fine that it is not a easy task in Blogger. By default, Blogger will remove these < > so that t…

SmartGWT vs GXT

Sanjiv Jivan has moved to Isomorphic Software and developed SmartGWT 1.0b2. It is a Google GWT wrapping around SmartClient. SmartGWT 1.0b2 is a stability release and contains various enhancements and bug fixes. GWT 1.6 M2 is also supported.

Ever since ExtJs changed the licensing model, GWT-Ext is considerably "dead". SmartGWT is the upcoming replacement for it.

When comparing to GXT, SmartGWT does have a "laggy" feeling when using the loaded application. The arguement is SmartGWT is a wrapper around SmartClient Ajax API while GXT provide pure Java code pruning.

Comparison Summary

SmartGWTOnly thing I am impressed about SmartGWT is their data binding and RestDataSource featureLGPL license => free. Rich UI featureset => very much like the old GXT. SmartGWT is JSNI wrap around GWT + SmartClient to create SmartGWT => slow GXTGXT data binding is kind of similar to the old GWT-EXT. GXT is pure GWT implementation => Fast, code pruning, custom js build GXT 2.0 is c…

Java - RSA encryption 117 Bytes limitation

There is a limitation on RSA encryption with large files and strings. That is, Java RSA has a encryption size limit of 117 bytes for PKCS v1.5 padding. This limitation is fine as RSA operation is computationally intensive and should be used for key exchange.But, if you really want to perform RSA encryption on large file, you will have to break the file into small block, ie, byte[100]. That is encrypt in 100 bytes and decrypt in 128 bytesSee http://www.aviransplace.com/2004/10/12/using-rsa-encryption-with-java/3/