วันพุธที่ 23 พฤศจิกายน พ.ศ. 2554

Why we can't find document.referer ?

INFO: Internet Explorer Does Not Send Referer Header in Unsecured Situations


When linking from one document to another in Internet Explorer 4.0 and later, the Referer header will not be sent when the link is from an HTTPS page to a non-HTTPS page. The Referer header also will not be sent when the link is from a non-HTTP(S) protocol, such as file://, to another page.

MORE INFORMATION

The Referer header is a standard HTTP header in the form of "Referer: <URL>," which indicates to a Web server the URL of the page that contained the hyperlink to the currently requested URL. When a user clicks on a link on "http://example.microsoft.com/default.htm" to "http://example.microsoft.com/test.htm," the theoretical example.microsoft.com Web server will be sent a referer header of the form "http://example.microsoft.com". 

However, Internet Explorer will not send the Referer header in situations that may result in secure data being sent accidentally to unsecured sites. For example, Internet Explorer will not send the Referer header for each of the following example hyperlinks from one document URL to another document URL:
  javascript:somejavascriptcode --> http://example.microsoft.com file://c:\alocalhtmlfile.htm  --> http://example.microsoft.com https://example.microsoft.com --> http://www.microsoft.com 					
This prevents local file names from being sent inadvertently to Web servers when linking from local content to Web sites that might snoop on such information. Also, many secure (HTTPS) Web servers store secure information such as credit-card data in the URL during a GET request to a CGI or ISAPI server application. This information can be unwittingly sent in the Referer header when linking out of an "https://" server to an "http://" server elsewhere on the Web. Internet Explorer attempts to prevent this bad practice by not sending the Referer header when transitioning from an HTTPS URL to a non-HTTPS URL.
http://support.microsoft.com/kb/178066

--
Im'


วันศุกร์ที่ 18 พฤศจิกายน พ.ศ. 2554

Exception in Java Programming

For awhile, I develop many enterprise software based on JavaEE Blue-Print Pattern. Basically, I have to write a three layer of Programming, Such as User-Interface, Service, Data Access.

I have seen some mistake about Exception used. For example, In UI-Layer which have to call 2-3 service. my co-worker always try-catch for each service call. That is not right.

private void uiAction(){
try {
// Call abcService

} catch (Exception ex){}

try {
// Call defService

} catch (Exception ex){}

}

What's the result?
This code will have a hidden bug about data-flow and it's hard to find.

It should be...


private void uiAction(){
try {

// Call abcService

// Call defService

} catch (Exception ex){
// Display an error to user.
alert(ex)
}

}

Just a simple pattern. You will meet a zero-defect soon. Don't hide any exception.

Anyway, There are 2 kind of Exception, One is Programmatic, Another one is Data-Flow Exception. So you should know how to handle for exception as well.