Archive for the ‘Java’ Category

JTidy and UTF-8 (international characters)

Tuesday, December 15th, 2009

To make JTidy work correctly with UTF-8 strings and process international characters in a proper way, use the following code:

JAVA:

  1. Document doc = Tidy.createEmptyDocument();
  2.         try {
  3.             doc = tidy.parseDOM(new InputStreamReader(IOUtils.toInputStream(html), "UTF-8"), new NullWriter());
  4.         } catch (UnsupportedEncodingException e) {
  5.             log.error(e);
  6.         }

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Tuesday, November 24th, 2009

If you are getting this exception from your Java program using HTTPClient library, that means the site you are trying to connect to has a test/self-signed or invalid certificate. The easiest way to workaround this problem is to grab InsecureSSLProtocolSocketFactory and InsecureTrustManager from HTMLUnit project and before making a request use this code:

JAVA:

  1. final ProtocolSocketFactory factory = new InsecureSSLProtocolSocketFactory();
  2. final Protocol https = new Protocol("https", factory, 443);
  3. Protocol.registerProtocol("https", https);

Java Geek Humor

Monday, March 10th, 2008

I've come across a really funny dialog here:

- I am looking for a downloadable java written practical test. We are in the process of employing some new staff and we need a test of some sorts to gauge the skills.
- Hey pls let me know ur company name.... ;-)
So that I can also apply...
- Upon reviewing your posting record we recommend you apply to
www.mcdonalds.com

RIA’s war

Thursday, August 2nd, 2007

RIA warIsn't this me-too RIA buzz a little bit naive? A long time ago Java "invented" applets - a great idea for RIA that has gracefully failed. Flash has taken the seat. MS's silverlight is not getting developers anywhere for too many reasons. JavaFX requires the latest Java JVM installed on the user's computer. I believe in the power of the Sun, but the UI is not their strongest side. Flex is the only way to go if you want to have a good-looking RIA application. Almost everybody has it installed and it is a really quick download if you don't have it. Great look, nice cooperation with J2EE technology.