2 weeks ago, someone called me direct via my office number. She spoke in Malay, but with some Indian accent. No offence, but I assumed that she is an Indian Lady (IL). She never introduce herself, only saying that she is calling from Kebajikan Pekerja-Pekerja something something (KPP). When I ask her that is this Kebajikan is from from the Govt body, she say yes.
Our teleconference is as such:
IL : Hello, ini Mr. Gary?
Me : Yes, saya.
IL : Oh, Mr. Gary. Tahniah ya. Mr. Gary teleh dipilih oleh KPP untuk menerima ticket kapal terbang percuma. Kita ada information Mr. Gary dan semua maklumat credit card Mr. Gary juga. Mr. Gary boleh bagi tau alamat Mr. Gary untuk saya hantar hadiah Mr. Gary?
Me : Ok. Boleh send to my office address. Alamat saya...
IL : Oh, Mr. Gary boleh bagi nama company dulu?
Me : XXXXX Sdn Bhd. Alamat 123, Jln 123, Off Jalan Kuchai Lama, 58200 KL.
IL : Ok. Mr. Gary. Mr. Gary ada credit card apa? Saya nak buat verification saja.
Me : Hmm... Saya ada Maybank Visa...
IL : Mr. Gary boleh baca expiry date credit card ini?
I started feeling suspicious. This is the first time I heard verification using expiry data.
Me : Errr... Itu saya tak tau ler. Saya punya dompet hilang hari itu. So saya punya credit card pun kena buat replacement. You next week call balik boleh tak? Saya perlu pergi bank collect credit card baru dulu.
IL : Ok. Minggu depan Wednesday boleh?
Me : Boleh. No problem. Bye bye.
After ended the call, the curiousity rise even more when they called me just after I lost my wallet less than 1 week ago. Ok la. Nevermind, I wait see how.
Sunday, August 23, 2009
Tuesday, August 18, 2009
Dev : Upload File Mimetype
Storing an uploaded file to the database is not as easy as just storing string information. Storing the attachment as just a physical file and other info such as path, file name, mimetype and size is much easier.
But how come, all these while uploading file was never an issue, only until recently? Clients complaint that whenever they upload a ".docx" file, error will occur. After some findings on the log file, the error is actually the mimetype size that I have set for the database table was insufficient. Mine was varchar(50), but yet insufficient. So how long do you actually need? As for me, I have increased my original varchar(50) to varchar(100).
Why this long? After reading this, you will know why. This is the problem with MS. I don't even know why they need it to be so long. Here's a list of office extension with its mimetype from the Net.
Extension MIMEType
.xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltx application/vnd.openxmlformats-officedocument.spreadsheetml.template
.potx application/vnd.openxmlformats-officedocument.presentationml.template
.ppsx application/vnd.openxmlformats-officedocument.presentationml.slideshow
.pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
.sldx application/vnd.openxmlformats-officedocument.presentationml.slide
.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template
But how come, all these while uploading file was never an issue, only until recently? Clients complaint that whenever they upload a ".docx" file, error will occur. After some findings on the log file, the error is actually the mimetype size that I have set for the database table was insufficient. Mine was varchar(50), but yet insufficient. So how long do you actually need? As for me, I have increased my original varchar(50) to varchar(100).
Why this long? After reading this, you will know why. This is the problem with MS. I don't even know why they need it to be so long. Here's a list of office extension with its mimetype from the Net.
Extension MIMEType
.xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltx application/vnd.openxmlformats-officedocument.spreadsheetml.template
.potx application/vnd.openxmlformats-officedocument.presentationml.template
.ppsx application/vnd.openxmlformats-officedocument.presentationml.slideshow
.pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
.sldx application/vnd.openxmlformats-officedocument.presentationml.slide
.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template
Dev : Download File With Semicolon
Created a spreadsheet, named as wifes_acc;children_acc.xls. Uploaded to an webapplication, and try to download it using IE7. WTF?! How come my spreadsheet became wifes_acc only after I click download. Where is there remaining name? How come the file was not found on the server?
Damn, what happened. Try with mozilla. Wow, it downloaded just fine. What happened?
We came across such problem when dealing with upload and download of attachment. After some finding on the Net, I realized that the actual problem lies with IE7. When ever user click the download button, we will execute "response.setHeader("xxxx")" on our coding to set the file name. In such, IE will always read the semicolon ";" in the header data as a delimiter for others parameters. Therefore, the name was actually splited into 2 parts.
Damn, an IE7 bug, hopefully such problem will be resolved in IE8.
Damn, what happened. Try with mozilla. Wow, it downloaded just fine. What happened?
We came across such problem when dealing with upload and download of attachment. After some finding on the Net, I realized that the actual problem lies with IE7. When ever user click the download button, we will execute "response.setHeader("xxxx")" on our coding to set the file name. In such, IE will always read the semicolon ";" in the header data as a delimiter for others parameters. Therefore, the name was actually splited into 2 parts.
Damn, an IE7 bug, hopefully such problem will be resolved in IE8.
Wednesday, July 08, 2009
Dev : Informix Inner Select
What if you are trying to create a virtual table for SQL?
As per standard database query, usually we would write something like:
SELECT some_fields FROM (SELECT selected_fields FROM table1) vtable
But in Informix, one of the much used relational database worldwide (but which I do not really like to use), had to be written in a slightly different way:
SELECT some_fields FROM TABLE(MULTISET(SELECT selected_fields FROM table1)) vtable
That's all. Not too much difference, but gosh, why on earth it has to be so complicating. Haha~~~
As per standard database query, usually we would write something like:
SELECT some_fields FROM (SELECT selected_fields FROM table1) vtable
But in Informix, one of the much used relational database worldwide (but which I do not really like to use), had to be written in a slightly different way:
SELECT some_fields FROM TABLE(MULTISET(SELECT selected_fields FROM table1)) vtable
That's all. Not too much difference, but gosh, why on earth it has to be so complicating. Haha~~~
Monday, June 01, 2009
Dev : Java Send Mail
Ever wonder why your application did not send the email out? Your code seems fine, but still fails. Single mail address is OK, but when coming to a list of emails, you're getting "550 5.1.1 User unknown" or some other error stating that one or more emails are not valid.
Well, this feature is actually intended by Sun. But I still want to send the email to the valid emails and how do we overcome this problem? Simple, by just added an extra line to the email property will do.
Normally, we would tell the mailserver what is the values for "mail.transport.protocol", "mail.smtp.host", "mail.host" and such, we just need to add in this "mail.smtp.sendpartial" and the value for it is true. With this, although the exception will still be thrown, but those with valid email will received the mail.
Of course, if you have cater for a resend if exception occurs, better check your code and list of emails. You would not want valid email owners keep on receiving the same mail over and over again. :)
Well, this feature is actually intended by Sun. But I still want to send the email to the valid emails and how do we overcome this problem? Simple, by just added an extra line to the email property will do.
Normally, we would tell the mailserver what is the values for "mail.transport.protocol", "mail.smtp.host", "mail.host" and such, we just need to add in this "mail.smtp.sendpartial" and the value for it is true. With this, although the exception will still be thrown, but those with valid email will received the mail.
Of course, if you have cater for a resend if exception occurs, better check your code and list of emails. You would not want valid email owners keep on receiving the same mail over and over again. :)
Tuesday, March 10, 2009
Dev : URL Extension
In your webpage, there is a hyperlink in your web is as such http://localhost:8080/webname/help.chm. You could not click it, as it will open as a garbage, alien language in your Internet Explorer. Have you come across with such problem?
No matter how I write the javascript, I can't manage to get it to "force" download using javascript. It will always open it as garbage. At last, I turn to my manager. He told me to use mime-mapping in web.xml.
After some research online, found that we can actually tell app server that such "extension" is a certain file type. As simple as 1-2-3, we just need to add these codes in the web.xml correctly. You might want to verify the placement.
<!-- set mime mapping for help file -->
<MIME-MAPPING>
<EXTENSION>chm</EXTENSION>
<MIME-TYPE>application/mshelp</MIME-TYPE>
</MIME-MAPPING>
Likewise, for other extension, we may put it as other mime-type, such as "application/pdf" for pdf, "application/vnd.ms-excel" for xls and others. You should be able to get the correct type by browsing the net.
After saving your web.xml, you just need to restart your app server and clear your temporary Internet file.
No matter how I write the javascript, I can't manage to get it to "force" download using javascript. It will always open it as garbage. At last, I turn to my manager. He told me to use mime-mapping in web.xml.
After some research online, found that we can actually tell app server that such "extension" is a certain file type. As simple as 1-2-3, we just need to add these codes in the web.xml correctly. You might want to verify the placement.
<!-- set mime mapping for help file -->
<MIME-MAPPING>
<EXTENSION>chm</EXTENSION>
<MIME-TYPE>application/mshelp</MIME-TYPE>
</MIME-MAPPING>
Likewise, for other extension, we may put it as other mime-type, such as "application/pdf" for pdf, "application/vnd.ms-excel" for xls and others. You should be able to get the correct type by browsing the net.
After saving your web.xml, you just need to restart your app server and clear your temporary Internet file.
Monday, November 24, 2008
Dev : MSSQL Server Case Sensitivity
Using database such as Oracle will insist that you use the correct case to do a select filter. But, if you use MSSQL 2000/2005, by default it is case-insensitive. You may need to choose it while in installation if I am not mistaken.
Thus, it means that:
select * from user where id = 'admin'
will always produce the same result as
select * from user where id = 'ADMIN'
if it is case_insensitive.
In this case, how would we make sure that our select statement always base on case sensitivity? Esspecially when comparing fields such as password where the case sensitivity is crucial?
Simple, just add 'COLLATE SQL_Latin1_General_CP1_CS_AS' at the end of the select statement to solve the matter.
Thus, by adding these words, it will always make sure that:
select * from user where id = 'admin' COLLATE SQL_Latin1_General_CP1_CS_AS
will always produce different result as
select * from user where id = 'ADMIN' COLLATE SQL_Latin1_General_CP1_CS_AS
If you want to ignore case sensitivity when by default is case-sensitive, then the SQL should be
select * from user where id = 'admin' COLLATE SQL_Latin1_General_CP1_CI_AS
Thus, it means that:
select * from user where id = 'admin'
will always produce the same result as
select * from user where id = 'ADMIN'
if it is case_insensitive.
In this case, how would we make sure that our select statement always base on case sensitivity? Esspecially when comparing fields such as password where the case sensitivity is crucial?
Simple, just add 'COLLATE SQL_Latin1_General_CP1_CS_AS' at the end of the select statement to solve the matter.
Thus, by adding these words, it will always make sure that:
select * from user where id = 'admin' COLLATE SQL_Latin1_General_CP1_CS_AS
will always produce different result as
select * from user where id = 'ADMIN' COLLATE SQL_Latin1_General_CP1_CS_AS
If you want to ignore case sensitivity when by default is case-sensitive, then the SQL should be
select * from user where id = 'admin' COLLATE SQL_Latin1_General_CP1_CI_AS
Thursday, November 13, 2008
Dev : Cannot find bean under name org.apache.struts.taglib.html.BEAN
I am getting this error - "Cannot find bean under name org.apache.struts.taglib.html.BEAN" when loading my jsp page. Something is wrong. What could it be?
At first, since it mentioned cannot find something, my thought was to check all my imported libraries. Nope, that wasn't the case. After some finding, finally I just realize that I have forgottten to put in the form name.
As for Struts framework's struts-html.tld to work properly in the page, we should always created the page as such:
<%@ taglib prefix="html" uri="/WEB-INF/struts-html.tld" %>
<html:form action="action_name_mapped_in_struts_config">
... some code...
</html:form>
This is to ensure that the correct naming and mapping is used when we are using struts-html tag.
At first, since it mentioned cannot find something, my thought was to check all my imported libraries. Nope, that wasn't the case. After some finding, finally I just realize that I have forgottten to put in the form name.
As for Struts framework's struts-html.tld to work properly in the page, we should always created the page as such:
<%@ taglib prefix="html" uri="/WEB-INF/struts-html.tld" %>
<html:form action="action_name_mapped_in_struts_config">
... some code...
</html:form>
This is to ensure that the correct naming and mapping is used when we are using struts-html tag.
Friday, August 15, 2008
Dev : MsSQL Drop Only If Exist
If you were to execute "DROP TABLE table1" or "ALTER TABLE table1 DROP COLUMN field1" in MsSQL server, probably you'll encouter error complaining the table or the column does not exist.
So how do you verify such table or column existed before you could drop them? There is a way. By querying the "INFORMATION_SCHEMA" table, you should be able to drop it without the concern of getting error.
Instead of "DROP TABLE table1", we can use
"if exists (SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE table_name = 'table1')
DROP TABLE table1".
And instead of "ALTER TABLE table1 DROP COLUMN field1", we can use
"if exists (SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'table1'
and column_name = 'field1')
alter table table1
drop column field1".
So how do you verify such table or column existed before you could drop them? There is a way. By querying the "INFORMATION_SCHEMA" table, you should be able to drop it without the concern of getting error.
Instead of "DROP TABLE table1", we can use
"if exists (SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE table_name = 'table1')
DROP TABLE table1".
And instead of "ALTER TABLE table1 DROP COLUMN field1", we can use
"if exists (SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'table1'
and column_name = 'field1')
alter table table1
drop column field1".
Wednesday, August 06, 2008
Dev : div vs span tag
Some of us may come across with the <div>and <span> tag before. What is the difference? Both usage seems almost the same.
Well, not exactly the same, but yes, almost. Both are elements of a document, but <div>is a block element and <span> is an inline element. And what is block and inline? Block elements take the whole section of a page, at least a whole full line, but inline will use as little space as possible, just like filling a gap.
DIV
I am <div>a</div>boy.
will produce
I am
yet,SPAN
I am <span>a</span> boy
will produce
I am a boy.
So, can you see the differences now?
Well, not exactly the same, but yes, almost. Both are elements of a document, but <div>is a block element and <span> is an inline element. And what is block and inline? Block elements take the whole section of a page, at least a whole full line, but inline will use as little space as possible, just like filling a gap.
DIV
I am <div>a</div>boy.
will produce
I am
a
boy.yet,SPAN
I am <span>a</span> boy
will produce
I am a boy.
So, can you see the differences now?
Subscribe to:
Posts (Atom)