Skip to main content


Showing posts from 2010

Easiest way to print Timestamp in Java

Rather than using Calendar.getTime() we can use java.sql.Timestamp class to get the time stamp which gives date and time till millisecond precision.

System.out.println(new Timestamp(System.currentTimeMillis()));

Above will give you current timestamp in this format: 2010-07-27 16:37:45.39

File upload problem: UTF-8 encoding not honored when form has multipart/form-data

The problem that I was facing was something like this. I was using Apache Commons File Upload library to upload and download some file.

I had a form in which user can upload a file and another field 'name' in which she can give any name to the file being loaded.

When I submitted the form, the file was uploaded fine but the value in name field was garbled. I followed all the possible suggestions I found:

<%@page pageEncoding="UTF-8"%> set. <%@page contentType="text/html;charset=UTF-8"%gt; set after the first directive. <meta equiv="Content-Type" content="text/html;charset=UTF-8"> in the head. enctype="multipart/form-data" attribute in the form. accept-charset="UTF-8" attribute in the form.
in the Servlet:
before doing any operations on request object: request.setCharacterEncoding("UTF-8"); For accessing the value

FileItem item = (FileItem);

if (item.isFormField()) {

//For regular…

Version number is a rocket science for Chrome users?

At least Google seems to think so. Take a look at any of the Chrome download pages here or the Beta download page here. Nowhere we see the version numbers. So unless you download a version and install it you won't know which version are you going to use!
Neat huh? Considering the fact that most of the Chrome users are early technology adopters and have switched from Firefox (which seems to give an overdose of versions!) this is moronic in my opinion.
There are other and better ways to keep your homepage clean but not specifying version numbers? I am not sure!

Gtalk and Twitter integration. Anyone?

I think before we woke up to Twitter, status messages in GTalk were (and are still are) the easiest way to spread a message, show off some geeky/cheesy/funny/wise quote or post your blog link for others to see without pushing it!

Now my Twitter is connected to my Facebook and when I post anything on Twitter, my Facebook status is updated.

But I still post blog/photo links in my gtalk status message and so do many of my contacts. So I was thinking yesterday if there is some mechanism which would let me post to Twitter as well. Just imagine, how cool it will be. I write something in Gtalk status message and that is posted on twitter and that goes to Facebook!

Now does Google provide an API which would let export/import status from GTalk status? Or do you know any such mechanism?