Mar
12
2009

Tips for installing Windows xp, vista and 7 without cd/dvd driver

Here i’ve gathered some links pointing to tips for installing windows xp, vista or 7 without cd/dvd driver (Imaging your laptop/notebook/netbook does not have an internal cd/dvd driver, and you don’t have an external one either.)

Windows xp

When windows xp came into market, the usb keys/external drivers are not as popular as they are now, nor is the volume of them. So windows xp is not designed with the function of installing from usb keys as I believe. However, the following link Installing Windows XP from USB provides information that helps you install windows xp from USB.

Windows Vista and  windows 7

It seems easier when it comes to windows vista and windows 7. The method of installing them from USB can be found from the link below:
Tips: How to boot/install Windows 7/Vista from USB Flash/Hard Drive

Feb
4
2009

Encode/Decode HTML in Java

It is often necessary to escape the special html code from the user input in case of avoiding cross site attack (XSS).

Initially i thought jdk provides a method somewhere to do this like function htmlentities() in php, but i failed to find it. All i found is a class called “URLEncoder ” which i don’t think can do this job.

I don’t want to reinvent the wheel as I believe there must be some java packages available that do this job. Googling “java encode html” didn’t lead me straight to the right java package (at least not the one I’d like to use).

After a while, I finally found one package i’d like to use. it’s from Apache Commons project, called “Commons Lang“. The method “StringEscapeUtils.escapeHtml(…) ” can do the encode job while the other method called unescapeHtml can do the decode job. So, I don’t have to write my own method… :)

Jan
8
2009

Ant: how to list files that are copied/compiled


Ant is a good tool to automate the project build / deploy process (especially for java projects). What’s more, it can also be an general tool used for file synchronization, backup and etc.

When i used ant to synchronize my folder in the desktop computer to my usb flash drive, i wanted to know what exact files have been copied over for synchronization. However, by default, ant only shows how many files have been copied over.

I tried adding option “–verbose” (or “-v”) to the ant command. But this option make the output too verbose to tell the copied files.

Finally, I found the solution. It’s actually very easy. In the “build.xml” file, for the “copy” task, just add the attribute “verbose” with the value “true”. For example:

<target name=”backup-download” description=”backup”>
<copy todir=”${todir}” verbose=”true”>
<fileset dir=”${download}” ></fileset>
</copy>
</target>

This “verbose” attribute is also available for the task “javac”, which means you can list java files that are actually compiled with this attribute turned on.

Dec
5
2008

derby db connecting problem (using ij)

derby db connecting problem (using ij)

This problem happened to me when i tried the apache derby database (now it’s also called java db, part of jdk 6).
Trying the following command in ij (the bundled simple console) just gave me an error like this “ERROR: Unable to establish connection”:

ij> connect “jdbc:derby://localhost/firstdb;create=true”;

It’s annoying, because i didn’t know what’s wrong from the error message.
Finally, i found out the reason, which is quite trivial. That is: i should not use the double quote (”) to quote the database url. Instead, i need to use single quote (’).

Maybe it’s documented somewhere in the derby documents, which , unfortunately, i missed.