<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pakzilla &#187; Java</title>
	<atom:link href="http://www.pakzilla.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pakzilla.com</link>
	<description>A blog on Programming, Web and Technology</description>
	<lastBuildDate>Sat, 04 Feb 2012 22:25:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>FUD: JDBC addiction and designing software for NoSQL</title>
		<link>http://www.pakzilla.com/2012/01/04/fuds-jdbc-addiction-and-designing-software-for-nosql/</link>
		<comments>http://www.pakzilla.com/2012/01/04/fuds-jdbc-addiction-and-designing-software-for-nosql/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 18:56:42 +0000</pubDate>
		<dc:creator>Tahir Akram</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[Porgramming]]></category>

		<guid isPermaLink="false">http://www.pakzilla.com/?p=1834</guid>
		<description><![CDATA[I am having a background of programming Java based web systems with RDBMS. Where I write a lot of JDBC code. Updates, select statements with a lot of joins, inserts etc is a part of my daily job. Most of my time consumed on maintaining the state of database, validating from base tables and after all storing [...]
Related posts:<ol>
<li><a href='http://www.pakzilla.com/2010/08/03/div-based-uis-heaven-or-hell-for-a-developer/' rel='bookmark' title='Div based UIs. Heaven or Hell for a developer?'>Div based UIs. Heaven or Hell for a developer?</a></li>
<li><a href='http://www.pakzilla.com/2010/08/12/struts-2-spring-integration-a-kickstart-on-using-dependency-injection/' rel='bookmark' title='Struts 2 Spring integration: a kickstart on using dependency injection'>Struts 2 Spring integration: a kickstart on using dependency injection</a></li>
<li><a href='http://www.pakzilla.com/2009/08/24/hashmap-vs-hashtable-vs-hashset/' rel='bookmark' title='HashMap vs Hashtable vs HashSet'>HashMap vs Hashtable vs HashSet</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I am having a background of programming Java based web systems with RDBMS. Where I write a lot of JDBC code. Updates, select statements with a lot of joins, inserts etc is a part of my daily job. Most of my time consumed on maintaining the state of database, validating from base tables and after all storing data in some tables. When I found I am consuming too much time over db programming, and JDBC code becoming a boiler plate across many modules. I included an annotation and reflection based ORM. And I feel happy with that. The object-entity mapper gives me the visualization of my storage in the form of objects. So life is currently going on living in relational DBs.</p>
<p>There is a question here. If I design my system in an object oriented way, why I need to store data in a relational database. You design your data model and then you need the overhead of some ORM to store your &#8220;objects&#8221; in the table. ORM libraries carries a cost. The library that I am using run extensive reflection calls and annotation parsing to compose SQL queries from my data model. It&#8217;s superb. Creates a lot of ease for me in handling with database. But it&#8217;s a layer itself and has its own cost in terms of performance.</p>
<p><img class="aligncenter size-full wp-image-1835" title="nosql" src="http://www.pakzilla.com/wp-content/new_upload/nosql.jpg" alt="" width="601" height="295" /></p>
<p>Working in the systems tightly designed to work with RDBMS has made it difficult for me to think my data model independent of any database where I am not going to use joins and a lot of tables etc. I am talking about NoSQL databases. I believe now its a controversy to design your object oriented system and gluing with a relational database. I just want to store my data. Why I need to solve the puzzles of normalization, indexes and other totally DBA related stuff. Where as I am just a web programmer. I just want the simplification of my application data storage. For this I need to change my perspective of designing the system from RDBMS to NoSQL. It&#8217;s challenging.</p>
<p>Because I am a JDBC addict.</p>
<p><em>Picture credit: Simran Jindal&#8217;s <a href="http://simranjindal.wordpress.com" target="_blank">blog</a></em></p>
<p>Related posts:<ol>
<li><a href='http://www.pakzilla.com/2010/08/03/div-based-uis-heaven-or-hell-for-a-developer/' rel='bookmark' title='Div based UIs. Heaven or Hell for a developer?'>Div based UIs. Heaven or Hell for a developer?</a></li>
<li><a href='http://www.pakzilla.com/2010/08/12/struts-2-spring-integration-a-kickstart-on-using-dependency-injection/' rel='bookmark' title='Struts 2 Spring integration: a kickstart on using dependency injection'>Struts 2 Spring integration: a kickstart on using dependency injection</a></li>
<li><a href='http://www.pakzilla.com/2009/08/24/hashmap-vs-hashtable-vs-hashset/' rel='bookmark' title='HashMap vs Hashtable vs HashSet'>HashMap vs Hashtable vs HashSet</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pakzilla.com/2012/01/04/fuds-jdbc-addiction-and-designing-software-for-nosql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to find mime type of a file in Java</title>
		<link>http://www.pakzilla.com/2011/12/31/how-to-find-mime-type-of-a-file-in-java/</link>
		<comments>http://www.pakzilla.com/2011/12/31/how-to-find-mime-type-of-a-file-in-java/#comments</comments>
		<pubDate>Sat, 31 Dec 2011 15:49:33 +0000</pubDate>
		<dc:creator>Tahir Akram</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Porgramming]]></category>

		<guid isPermaLink="false">http://www.pakzilla.com/?p=1803</guid>
		<description><![CDATA[Validating a file when it is getting uploaded in the system is some time very necessary. We can check the extension of the file, but what if user has changed the extension to crack the system. So the best way is to find the mime type. There are multiple libraries that you can use to [...]
Related posts:<ol>
<li><a href='http://www.pakzilla.com/2010/07/16/fetch-twitter-friends-or-followers-through-rest-api-in-java/' rel='bookmark' title='Fetch Twitter friends or followers through REST API in Java'>Fetch Twitter friends or followers through REST API in Java</a></li>
<li><a href='http://www.pakzilla.com/2012/01/04/fuds-jdbc-addiction-and-designing-software-for-nosql/' rel='bookmark' title='FUD: JDBC addiction and designing software for NoSQL'>FUD: JDBC addiction and designing software for NoSQL</a></li>
<li><a href='http://www.pakzilla.com/2009/04/09/java-in-google-app-engine-whats-new-for-developers/' rel='bookmark' title='Java in Google App Engine, what&#8217;s new for developers'>Java in Google App Engine, what&#8217;s new for developers</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Validating a file when it is getting uploaded in the system is some time very necessary. We can check the extension of the file, but what if user has changed the extension to crack the system. So the best way is to find the mime type. There are multiple libraries that you can use to get the mime type of a file. Java 6 IO APIs can&#8217;t do that. I used <strong>JMimeMagic</strong> for this. Following is a code snippet to get the mime type of a file.</p>
<pre class="brush: java; title: ; notranslate">
MagicMatch match = Magic.getMagicMatch(getPromotionOptIn().getUpload(),false);
String mimeType = match.getMimeType();
</pre>
<p>You can download JMimeMagic lib from <a href="http://sourceforge.net/projects/jmimemagic/" target="_blank">here</a>.</p>
<p>JMimeMagic requires a dependency, that is <strong>Jakarata ORO</strong>. Jar can be downloaded from Apache <a href="http://archive.apache.org/dist/jakarta/oro/" target="_blank">archives</a>.</p>
<p>Related posts:<ol>
<li><a href='http://www.pakzilla.com/2010/07/16/fetch-twitter-friends-or-followers-through-rest-api-in-java/' rel='bookmark' title='Fetch Twitter friends or followers through REST API in Java'>Fetch Twitter friends or followers through REST API in Java</a></li>
<li><a href='http://www.pakzilla.com/2012/01/04/fuds-jdbc-addiction-and-designing-software-for-nosql/' rel='bookmark' title='FUD: JDBC addiction and designing software for NoSQL'>FUD: JDBC addiction and designing software for NoSQL</a></li>
<li><a href='http://www.pakzilla.com/2009/04/09/java-in-google-app-engine-whats-new-for-developers/' rel='bookmark' title='Java in Google App Engine, what&#8217;s new for developers'>Java in Google App Engine, what&#8217;s new for developers</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pakzilla.com/2011/12/31/how-to-find-mime-type-of-a-file-in-java/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Calling Posterous API in Java</title>
		<link>http://www.pakzilla.com/2011/11/03/calling-posterous-api-in-java/</link>
		<comments>http://www.pakzilla.com/2011/11/03/calling-posterous-api-in-java/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 10:43:48 +0000</pubDate>
		<dc:creator>Tahir Akram</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Porgramming]]></category>
		<category><![CDATA[Posterous API]]></category>

		<guid isPermaLink="false">http://www.pakzilla.com/?p=1687</guid>
		<description><![CDATA[I was playing with Posterous API to call it in Java program. If you guys want to call Posterous API, you need to get API Token from Posterous API Docs first. This API Token (api_token) will go with every URL that you will invoke in your code. I was missing this token and was wondering [...]
Related posts:<ol>
<li><a href='http://www.pakzilla.com/2010/07/16/fetch-twitter-friends-or-followers-through-rest-api-in-java/' rel='bookmark' title='Fetch Twitter friends or followers through REST API in Java'>Fetch Twitter friends or followers through REST API in Java</a></li>
<li><a href='http://www.pakzilla.com/2010/03/01/how-to-use-and-retain-twitter4j-oauth-access-token/' rel='bookmark' title='How to use and retain Twitter4J OAuth access token'>How to use and retain Twitter4J OAuth access token</a></li>
<li><a href='http://www.pakzilla.com/2010/04/05/configure-custom-subdomain-with-posterous-blog/' rel='bookmark' title='Configure custom subdomain with Posterous blog'>Configure custom subdomain with Posterous blog</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I was playing with Posterous API to call it in Java program. If you guys want to call Posterous API, you need to get API Token from <a href="http://posterous.com/api" target="_blank">Posterous API Docs</a> first. This API Token (api_token) will go with every URL that you will invoke in your code.</p>
<p>I was missing this token and was wondering why I am getting HTTP 401 authentication failure. Well you can use following class to use Posterous API in Java.</p>
<p><img class="aligncenter size-full wp-image-1691" title="Posterous API Reference" src="http://www.pakzilla.com/wp-content/upload/Posterous-API-Reference_1320315452776.png" alt="" width="611" height="191" /></p>
<pre class="brush: java; title: ; notranslate">
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL;
import java.net.URLConnection;

public class AuthPosterous {
	private static BufferedReader data;

	  public static void authenticateHttpRequest(String webAddress, String username, String password) throws Exception {
	      Authenticator.setDefault(new MyAuthenticator(username, password));
	      URL url = new URL(webAddress);
	      URLConnection connection = url.openConnection();
	      data = new BufferedReader( new InputStreamReader(connection.getInputStream()) );
	  }

	  public static String readHttpRequest() throws Exception {
	      StringBuilder builder = new StringBuilder();
	      for (String line = null; (line = data.readLine()) != null;) {
	          builder.append(line).append(&quot;\n&quot;);
	      }
	      return builder.toString();
	  }

	  protected static class MyAuthenticator extends Authenticator {
	      private String username, password;
	      public MyAuthenticator(String user, String pwd) {
	          username = user;
	          password = pwd;
	      }
	      protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password.toCharArray()); }
	  }

	    public static void main (String arg[]){
	        try {
	        	String yourPosterousUsername= &quot;&lt;yourEmailAsUserName&gt;&quot;, yourPassword = &quot;&lt;yourPassword&gt;&quot;,
	        		theAPIURL=&quot;http://posterous.com/api/2/users/me?api_token=&lt;get_API_Token_From_Posterous_Docs&gt;&quot;;
	        	/* get your API token from http://posterous.com/api */
	            AuthPosterous.authenticateHttpRequest(theAPIURL, yourPosterousUsername,yourPassword);
	              String readData = AuthPosterous.readHttpRequest();
	              System.out.println(readData);
	            }catch (Exception e) {
	                e.printStackTrace();
	            }
	    }
	}
</pre>
<p>Related posts:<ol>
<li><a href='http://www.pakzilla.com/2010/07/16/fetch-twitter-friends-or-followers-through-rest-api-in-java/' rel='bookmark' title='Fetch Twitter friends or followers through REST API in Java'>Fetch Twitter friends or followers through REST API in Java</a></li>
<li><a href='http://www.pakzilla.com/2010/03/01/how-to-use-and-retain-twitter4j-oauth-access-token/' rel='bookmark' title='How to use and retain Twitter4J OAuth access token'>How to use and retain Twitter4J OAuth access token</a></li>
<li><a href='http://www.pakzilla.com/2010/04/05/configure-custom-subdomain-with-posterous-blog/' rel='bookmark' title='Configure custom subdomain with Posterous blog'>Configure custom subdomain with Posterous blog</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pakzilla.com/2011/11/03/calling-posterous-api-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>From 1st September 10, Sun Certification titles will be changed to Oracle Certification</title>
		<link>http://www.pakzilla.com/2010/08/31/from-1st-september-10-sun-certification-titles-will-be-changed-to-oracle-certification/</link>
		<comments>http://www.pakzilla.com/2010/08/31/from-1st-september-10-sun-certification-titles-will-be-changed-to-oracle-certification/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 10:06:55 +0000</pubDate>
		<dc:creator>Tahir Akram</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Certification]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Software Industry]]></category>
		<category><![CDATA[Sun]]></category>

		<guid isPermaLink="false">http://www.pakzilla.com/?p=1183</guid>
		<description><![CDATA[Just came to know from Oracle website that they have completely integrated Sun certifications with Oracle certification program. The title of certification has been changed. Now Sun Certified Java Programmer will be know as Oracle Certified Professional, Java Programmer. From Oracle website: Effective September 1, 2010, all Java, Oracle Solaris, MySQL, Open Office and Oracle [...]
Related posts:<ol>
<li><a href='http://www.pakzilla.com/2009/08/28/scjp-plus-beta-certification-exam-delayed/' rel='bookmark' title='SCJP Plus Beta Certification exam delayed'>SCJP Plus Beta Certification exam delayed</a></li>
<li><a href='http://www.pakzilla.com/2010/03/20/java-certification-voucher-in-40-till-31st-march-2010-for-students/' rel='bookmark' title='Java certification voucher in $40 till 31st March 2010 for students'>Java certification voucher in $40 till 31st March 2010 for students</a></li>
<li><a href='http://www.pakzilla.com/2009/04/22/oracle-has-acquired-sun-microsystems-so-whats-the-impact/' rel='bookmark' title='Oracle has acquired SUN Microsystems. So whats the impact?'>Oracle has acquired SUN Microsystems. So whats the impact?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Just came to know from Oracle website that they have completely integrated Sun certifications with Oracle certification program. The title of certification has been changed. Now Sun Certified Java Programmer will be know as Oracle Certified Professional, Java Programmer.<br />
From <a href="http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=433&amp;p_org_id=1001&amp;lang=US">Oracle</a> website:</p>
<blockquote><p>Effective September 1, 2010, all Java, Oracle Solaris, MySQL, Open Office and Oracle Solaris Cluster certifications have been re-published and rebranded under the Oracle Certification Program. This change will not impact any of the exam objectives and with Oracle’s firm commitment to the growth of the program, these credentials will continue to be some of the highest recognized achievements in the industry.</p></blockquote>
<p>Related posts:<ol>
<li><a href='http://www.pakzilla.com/2009/08/28/scjp-plus-beta-certification-exam-delayed/' rel='bookmark' title='SCJP Plus Beta Certification exam delayed'>SCJP Plus Beta Certification exam delayed</a></li>
<li><a href='http://www.pakzilla.com/2010/03/20/java-certification-voucher-in-40-till-31st-march-2010-for-students/' rel='bookmark' title='Java certification voucher in $40 till 31st March 2010 for students'>Java certification voucher in $40 till 31st March 2010 for students</a></li>
<li><a href='http://www.pakzilla.com/2009/04/22/oracle-has-acquired-sun-microsystems-so-whats-the-impact/' rel='bookmark' title='Oracle has acquired SUN Microsystems. So whats the impact?'>Oracle has acquired SUN Microsystems. So whats the impact?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pakzilla.com/2010/08/31/from-1st-september-10-sun-certification-titles-will-be-changed-to-oracle-certification/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Struts 2 Spring integration: a kickstart on using dependency injection</title>
		<link>http://www.pakzilla.com/2010/08/12/struts-2-spring-integration-a-kickstart-on-using-dependency-injection/</link>
		<comments>http://www.pakzilla.com/2010/08/12/struts-2-spring-integration-a-kickstart-on-using-dependency-injection/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 10:35:16 +0000</pubDate>
		<dc:creator>Tahir Akram</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.pakzilla.com/?p=1110</guid>
		<description><![CDATA[In this post you will find how we can integrate Spring with Struts2 through struts2-spring-plugin. And we will also see how we can use dependency injection. I assume that you are successfully running a Struts2 application. We will add our Spring integration code in that. Lets take a scenario. You have an Interface DAO.java that [...]
Related posts:<ol>
<li><a href='http://www.pakzilla.com/2007/04/08/accessing-a-selected-row-from-hdatatable/' rel='bookmark' title='Accessing a selected row from h:dataTable'>Accessing a selected row from h:dataTable</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In this post you will find how we can integrate Spring with Struts2 through struts2-spring-plugin. And we will also see how we can use dependency injection. I assume that you are successfully running a Struts2 application. We will add our Spring integration code in that.</p>
<p>Lets take a scenario. You have an Interface DAO.java that has abstract methods. You have written separate implementation for it. Lets suppose for different databases. So we are going to use the implementation of this DAO in our Struts2 application.</p>
<p>DAO.java</p>
<pre class="brush: java; title: ; notranslate">package com.pakzilla;
public interface DAO {
public void save(Object o);
}</pre>
<p>DAOOracle.java</p>
<pre class="brush: java; title: ; notranslate">package com.pakzilla;
public class DAOOracle implements DAO {

public void save(Object o) {
System.out.println(&quot;Oracle implementaion&quot;);
}
}</pre>
<p>DAOMySQL.java</p>
<pre class="brush: java; title: ; notranslate">package com.pakzilla;
public class DAOMySQL implements DAO {

public void save(Object o) {
System.out.println(&quot;MySQL implementaion&quot;);
}
}</pre>
<p>DAOService .java</p>
<pre class="brush: java; title: ; notranslate">package com.pakzilla;
public class DAOService {
private DAO dao;

public void setDao(DAO _dao){
this.dao = _dao;
}

public DAO getDao(){
return dao;
}

public void saveRecord(Object o){
dao.save(o);
}
}</pre>
<p>applicationContext.xml. You will put this file in JavaSource. So it will become the part of your classpath.</p>
<pre class="brush: xml; title: ; notranslate">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN//EN&quot; &quot;http://www.springframework.org/dtd/spring-beans.dtd&quot;&gt;
&lt;beans&gt;

&lt;bean id=&quot;daoOracle&quot; class=&quot;com.pakzilla.DAOOracle&quot; /&gt;
&lt;bean id=&quot;daoMysql&quot;   class=&quot;com.pakzilla.DAOMySQL&quot;/&gt;

&lt;bean id=&quot;daoService&quot; class=&quot;com.pakzilla.DAOService&quot;&gt;
&lt;property name=&quot;dao&quot;&gt;
&lt;!-- swith the daos here --&gt;
&lt;ref local=&quot;daoMysql&quot;/&gt;
&lt;/property&gt;
&lt;/bean&gt;
&lt;/beans&gt;
</pre>
<p>Add following in web.xml. You see we are using classpath prefix with applicationContext.xml. Because this file will be in our classpaths. And on server startup web.xml will load it.</p>
<pre class="brush: xml; title: ; notranslate">

&lt;context-param&gt;
&lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
&lt;param-value&gt;
classpath:applicationContext.xml
&lt;/param-value&gt;
&lt;/context-param&gt;

&lt;listener&gt;
&lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
&lt;/listener&gt;</pre>
<p>Somewhere in your Struts2 Action, where you want to insert the record.</p>
<pre class="brush: java; title: ; notranslate">ApplicationContext context =
       new ClassPathXmlApplicationContext(&quot;applicationContext.xml&quot;);
DAOService daoService = (DAOService) context.getBean(&quot;daoService&quot;);
daoService.saveRecord(&lt;your object to save&gt;);</pre>
<p>You must have following jars in your classpath.</p>
<pre class="brush: xml; title: ; notranslate">
antlr-runtime-3.0.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-logging-1.1.jar
freemarker-2.3.13.jar
junit-3.8.1.jar
ognl-2.6.11.jar
org.springframework.asm-3.0.0.M3.jar
org.springframework.beans-3.0.0.M3.jar
org.springframework.context-3.0.0.M3.jar
org.springframework.core-3.0.0.M3.jar
org.springframework.expression-3.0.0.M3.jar
org.springframework.web-3.0.0.M3.jar
org.springframework.web.servlet-3.0.0.M3.jar
spring.jar
struts2-convention-plugin-2.1.6.jar
struts2-core-2.1.6.jar
struts2-spring-plugin-2.1.6.jar
xwork-2.1.2.jar
</pre>
<p>Related posts:<ol>
<li><a href='http://www.pakzilla.com/2007/04/08/accessing-a-selected-row-from-hdatatable/' rel='bookmark' title='Accessing a selected row from h:dataTable'>Accessing a selected row from h:dataTable</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pakzilla.com/2010/08/12/struts-2-spring-integration-a-kickstart-on-using-dependency-injection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Div based UIs. Heaven or Hell for a developer?</title>
		<link>http://www.pakzilla.com/2010/08/03/div-based-uis-heaven-or-hell-for-a-developer/</link>
		<comments>http://www.pakzilla.com/2010/08/03/div-based-uis-heaven-or-hell-for-a-developer/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 22:06:23 +0000</pubDate>
		<dc:creator>Tahir Akram</dc:creator>
				<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.pakzilla.com/?p=1096</guid>
		<description><![CDATA[At my work I have a large application that has all web pages in table based layout. The use of Div is just limited to hide and show some content area on web page. Same is the case with CSS. Using them for styling fonts and some formatting for tables. Like every developer (not designer) [...]
Related posts:<ol>
<li><a href='http://www.pakzilla.com/2012/01/09/programmer-vs-developer-vs-architect/' rel='bookmark' title='Programmer vs Developer vs Architect'>Programmer vs Developer vs Architect</a></li>
<li><a href='http://www.pakzilla.com/2010/08/02/how-the-mind-of-a-web-developer-works/' rel='bookmark' title='How the mind of a web developer works?'>How the mind of a web developer works?</a></li>
<li><a href='http://www.pakzilla.com/2007/04/08/ten-things-every-java-developer-should-know-about-unix/' rel='bookmark' title='Ten things every Java developer should know about UNIX'>Ten things every Java developer should know about UNIX</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>At my work I have a large application that has all web pages in table based layout. The use of Div is just limited to hide and show some content area on web page. Same is the case with CSS. Using them for styling fonts and some formatting for tables. Like every developer (not designer) I am very comfortable in developing  UIs by using tables. But quite impressed with Div based layouts, as its a fashion thing for web pages. I see how gracefully div is helping to manage contents instead of tr and tds. Whenever I visit some site that has some good layout. I hit the view source of that page to see whether the designer/developer has used tables. And almost all of time I find myself alone loving tables. And I know the cost to manage a big web page all developed in table. What happen if some td missed. And I need to do the debugging by enabling the border of tables. Ehh.<img class="alignright size-full wp-image-1098" title="heaven-or-hell" src="http://www.pakzilla.com/wp-content/upload/heaven-or-hell.jpg" alt="" width="252" height="336" /></p>
<p>Its been several years people started developing UIs in Divs. Now no one is working on tables. But if you want to shift on developing UI in Div, you need a learning curve on CSS. So what happen here? It has increased the cost of your time to develop a web page. Unless you master yourself in CSS. Huh?</p>
<p>So being a Java developer, should I master myself in CSS things too. If I am an independent (solo performer) developer that want to develop some app. First thing that came in my mind is, what happen when people will hit view source button. And will it not increase my time to deliver a thing. What should I consider, the features in my application? or the fear of developing the web pages in divs?</p>
<p>Related posts:<ol>
<li><a href='http://www.pakzilla.com/2012/01/09/programmer-vs-developer-vs-architect/' rel='bookmark' title='Programmer vs Developer vs Architect'>Programmer vs Developer vs Architect</a></li>
<li><a href='http://www.pakzilla.com/2010/08/02/how-the-mind-of-a-web-developer-works/' rel='bookmark' title='How the mind of a web developer works?'>How the mind of a web developer works?</a></li>
<li><a href='http://www.pakzilla.com/2007/04/08/ten-things-every-java-developer-should-know-about-unix/' rel='bookmark' title='Ten things every Java developer should know about UNIX'>Ten things every Java developer should know about UNIX</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pakzilla.com/2010/08/03/div-based-uis-heaven-or-hell-for-a-developer/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>New topics added in SCJP 6 Certification (CX-310-065)</title>
		<link>http://www.pakzilla.com/2010/07/17/new-topics-added-in-scjp-6-certification-cx-310-065/</link>
		<comments>http://www.pakzilla.com/2010/07/17/new-topics-added-in-scjp-6-certification-cx-310-065/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 09:29:44 +0000</pubDate>
		<dc:creator>Tahir Akram</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[SCJP]]></category>

		<guid isPermaLink="false">http://www.pakzilla.com/?p=1087</guid>
		<description><![CDATA[Following are the points that are highlighted in Kathi Sierra and Bert Bates book on SCJP6. 1-    Console class. 2-    NavigableSet and NavigableMap. 3-    Lower(int) and higher(int) function are added in Treeset collection. 4-    Polling method in TreeSet and TreeMap. 5-    TreeSet.descendingSet() and TreeMap.descendingMap(). Thanks to Bilal for discussing these points with me. Related posts: [...]
Related posts:<ol>
<li><a href='http://www.pakzilla.com/2009/08/28/scjp-plus-beta-certification-exam-delayed/' rel='bookmark' title='SCJP Plus Beta Certification exam delayed'>SCJP Plus Beta Certification exam delayed</a></li>
<li><a href='http://www.pakzilla.com/2010/01/27/i-have-started-preparing-for-scjp/' rel='bookmark' title='I have started preparing for SCJP'>I have started preparing for SCJP</a></li>
<li><a href='http://www.pakzilla.com/2010/08/31/from-1st-september-10-sun-certification-titles-will-be-changed-to-oracle-certification/' rel='bookmark' title='From 1st September 10, Sun Certification titles will be changed to Oracle Certification'>From 1st September 10, Sun Certification titles will be changed to Oracle Certification</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Following are the points that are highlighted in Kathi Sierra and Bert Bates book on SCJP6.</p>
<p>1-    Console class.<br />
2-    NavigableSet and NavigableMap.<br />
3-    Lower(int) and higher(int) function are added in Treeset collection.<br />
4-    Polling method in TreeSet and TreeMap.<br />
5-    TreeSet.descendingSet() and TreeMap.descendingMap().</p>
<p>Thanks to Bilal for discussing these points with me.</p>
<p>Related posts:<ol>
<li><a href='http://www.pakzilla.com/2009/08/28/scjp-plus-beta-certification-exam-delayed/' rel='bookmark' title='SCJP Plus Beta Certification exam delayed'>SCJP Plus Beta Certification exam delayed</a></li>
<li><a href='http://www.pakzilla.com/2010/01/27/i-have-started-preparing-for-scjp/' rel='bookmark' title='I have started preparing for SCJP'>I have started preparing for SCJP</a></li>
<li><a href='http://www.pakzilla.com/2010/08/31/from-1st-september-10-sun-certification-titles-will-be-changed-to-oracle-certification/' rel='bookmark' title='From 1st September 10, Sun Certification titles will be changed to Oracle Certification'>From 1st September 10, Sun Certification titles will be changed to Oracle Certification</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pakzilla.com/2010/07/17/new-topics-added-in-scjp-6-certification-cx-310-065/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fetch Twitter friends or followers through REST API in Java</title>
		<link>http://www.pakzilla.com/2010/07/16/fetch-twitter-friends-or-followers-through-rest-api-in-java/</link>
		<comments>http://www.pakzilla.com/2010/07/16/fetch-twitter-friends-or-followers-through-rest-api-in-java/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 11:08:18 +0000</pubDate>
		<dc:creator>Tahir Akram</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Twitter API]]></category>

		<guid isPermaLink="false">http://www.pakzilla.com/?p=1082</guid>
		<description><![CDATA[I was playing around with fetching Twitter followers and friends with Twitter4J. But it was taking time to do that. So I code it with using REST urls given by Twitter. It fetches all your friends or followers. Depending upon your application that you want one list or you want to use paging. But I [...]
Related posts:<ol>
<li><a href='http://www.pakzilla.com/2011/11/03/calling-posterous-api-in-java/' rel='bookmark' title='Calling Posterous API in Java'>Calling Posterous API in Java</a></li>
<li><a href='http://www.pakzilla.com/2010/03/01/how-to-use-and-retain-twitter4j-oauth-access-token/' rel='bookmark' title='How to use and retain Twitter4J OAuth access token'>How to use and retain Twitter4J OAuth access token</a></li>
<li><a href='http://www.pakzilla.com/2009/10/03/tutorial-java-based-twitter-app-on-google-app-engine/' rel='bookmark' title='Tutorial: Java based Twitter App on Google App Engine'>Tutorial: Java based Twitter App on Google App Engine</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I was playing around with fetching Twitter followers and friends with Twitter4J. But it was taking time to do that. So I code it with using REST urls given by Twitter. It fetches all your friends or followers. Depending upon your application that you want one list or you want to use paging. But I did it in one go. Performance wise, it will be trouble of fetching say 2000 followers or friends.</p>
<p>I used JDOM to parse XML.</p>
<pre class="brush: java; title: ; notranslate">
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;

public class Twt {

String urlFlwrs= &quot;http://twitter.com/statuses/followers/YOUR_TWITTER_SCREEN_NAME.xml?cursor=&quot;;
String urlFrnds= &quot;http://twitter.com/statuses/friends/YOUR_TWITTER_SCREEN_NAME.xml?cursor=&quot;;

List followers = new ArrayList();
long cursorCounter = -1;

public static void main(String[] args) {
long start = System.currentTimeMillis();
new Twt().readFollowFriends();
System.out.printf(&quot;Total Time: %d secs&quot;,
(System.currentTimeMillis() - start)/1000);
}

void readFollowFriends(){

try {
StringBuffer followersData = new StringBuffer();
// use urlFrnds as a parameter if you want to fetch friends
URL url = new URL(urlFlwrs+cursorCounter);
URLConnection urlConnection = url.openConnection();
DataInputStream dis = new DataInputStream(
urlConnection.getInputStream());
String inputLine;
while ((inputLine = dis.readLine()) != null) {
followersData.append(inputLine);
}

SAXBuilder builder = new SAXBuilder();
Document document = builder.build(new ByteArrayInputStream(
followersData.toString().getBytes()));

Element root = document.getRootElement();
Element usersElm = root.getChild(&quot;users&quot;);
Element nextCursor = root.getChild(&quot;next_cursor&quot;);
List users = usersElm.getChildren(&quot;user&quot;);

for (int c = 0; c &lt; users.size(); c++) {
Element user = (Element) users.get(c);
Element name = user.getChild(&quot;name&quot;);
// now you have every thing, the information of a user
// here you can populate followers list
}

if (nextCursor != null){
cursorCounter = Long.parseLong(nextCursor.getText());

if (cursorCounter != 0)
readFollowFriends();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
</pre>
<p>But you will also get following <a href="http://twitterapi.pbworks.com/HTTP-Response-Codes-and-Errors">HTTP 400 error</a>. Due to <a href="http://twitterapi.pbworks.com/Rate-limiting">API limits</a> by Twitter. For this we want to <a href="http://twitter.com/help/request_whitelisting">whitelist</a> ourself.</p>
<pre class="brush: java; title: ; notranslate">
java.io.IOException: Server returned HTTP response code: 400 for URL: http://twitter.com/statuses/followers/YOUR_TWITTER_SCREEN_NAME.xml?cursor=-1
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1133)
at Twt.readFollowFriends(Twt.java:32)
at Twt.main(Twt.java:22)
Total Time: 7 secs
</pre>
<p>Related posts:<ol>
<li><a href='http://www.pakzilla.com/2011/11/03/calling-posterous-api-in-java/' rel='bookmark' title='Calling Posterous API in Java'>Calling Posterous API in Java</a></li>
<li><a href='http://www.pakzilla.com/2010/03/01/how-to-use-and-retain-twitter4j-oauth-access-token/' rel='bookmark' title='How to use and retain Twitter4J OAuth access token'>How to use and retain Twitter4J OAuth access token</a></li>
<li><a href='http://www.pakzilla.com/2009/10/03/tutorial-java-based-twitter-app-on-google-app-engine/' rel='bookmark' title='Tutorial: Java based Twitter App on Google App Engine'>Tutorial: Java based Twitter App on Google App Engine</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pakzilla.com/2010/07/16/fetch-twitter-friends-or-followers-through-rest-api-in-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java certification voucher in $40 till 31st March 2010 for students</title>
		<link>http://www.pakzilla.com/2010/03/20/java-certification-voucher-in-40-till-31st-march-2010-for-students/</link>
		<comments>http://www.pakzilla.com/2010/03/20/java-certification-voucher-in-40-till-31st-march-2010-for-students/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 10:14:10 +0000</pubDate>
		<dc:creator>Tahir Akram</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Certification]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Porgramming]]></category>
		<category><![CDATA[SCJP]]></category>
		<category><![CDATA[Sun]]></category>

		<guid isPermaLink="false">http://www.pakzilla.com/?p=859</guid>
		<description><![CDATA[From a recent announcement from Oracle under Sun Academic Initiative program (SAI). Now students can get Java certification voucher in $40 till 31st March 2010. This is an excellent opportunity for students. After this date they will give 40% discount on the actual price of the exam fee. Read more on SAI home page: All [...]
Related posts:<ol>
<li><a href='http://www.pakzilla.com/2010/08/31/from-1st-september-10-sun-certification-titles-will-be-changed-to-oracle-certification/' rel='bookmark' title='From 1st September 10, Sun Certification titles will be changed to Oracle Certification'>From 1st September 10, Sun Certification titles will be changed to Oracle Certification</a></li>
<li><a href='http://www.pakzilla.com/2009/08/28/scjp-plus-beta-certification-exam-delayed/' rel='bookmark' title='SCJP Plus Beta Certification exam delayed'>SCJP Plus Beta Certification exam delayed</a></li>
<li><a href='http://www.pakzilla.com/2010/01/27/i-have-started-preparing-for-scjp/' rel='bookmark' title='I have started preparing for SCJP'>I have started preparing for SCJP</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-861" title="oracle-sun" src="http://www.pakzilla.com/wp-content/upload/oracle-sun.png" alt="" width="138" height="88" />From a recent announcement from Oracle under <a href="http://www.sun.com/solutions/landing/industry/education/sai/">Sun Academic Initiative</a> program (SAI). Now students can get Java certification voucher in $40 till 31st March 2010. This is an excellent opportunity for students. After this date they will give 40% discount on the actual price of the exam fee.</p>
<p>Read more on <a href="http://www.sun.com/solutions/landing/industry/education/sai/">SAI</a> home page:</p>
<blockquote><p>All SAI members may purchase the $40 discount vouchers until March  31, 2010 at <a href="http://saic.educationservicesgroup.com/" target="_blank">saic.educationservicesgroup.com/</a> and redeem the  vouchers at Prometric testing centers through the expiration dates. The  voucher instructions and expiration dates are sent via email when  members purchase the vouchers.</p>
<p>After March 31, 2010, all SAI members may obtain 40% off discount  vouchers by emailing: <a href="mailto:contact_sai@sun.com">contact_sai@sun.com</a></p></blockquote>
<p>Related posts:<ol>
<li><a href='http://www.pakzilla.com/2010/08/31/from-1st-september-10-sun-certification-titles-will-be-changed-to-oracle-certification/' rel='bookmark' title='From 1st September 10, Sun Certification titles will be changed to Oracle Certification'>From 1st September 10, Sun Certification titles will be changed to Oracle Certification</a></li>
<li><a href='http://www.pakzilla.com/2009/08/28/scjp-plus-beta-certification-exam-delayed/' rel='bookmark' title='SCJP Plus Beta Certification exam delayed'>SCJP Plus Beta Certification exam delayed</a></li>
<li><a href='http://www.pakzilla.com/2010/01/27/i-have-started-preparing-for-scjp/' rel='bookmark' title='I have started preparing for SCJP'>I have started preparing for SCJP</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pakzilla.com/2010/03/20/java-certification-voucher-in-40-till-31st-march-2010-for-students/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to use and retain Twitter4J OAuth access token</title>
		<link>http://www.pakzilla.com/2010/03/01/how-to-use-and-retain-twitter4j-oauth-access-token/</link>
		<comments>http://www.pakzilla.com/2010/03/01/how-to-use-and-retain-twitter4j-oauth-access-token/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 20:41:34 +0000</pubDate>
		<dc:creator>Tahir Akram</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Twitter API]]></category>
		<category><![CDATA[Google App Engine]]></category>
		<category><![CDATA[OAuth]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Twitter4J]]></category>

		<guid isPermaLink="false">http://www.pakzilla.com/?p=831</guid>
		<description><![CDATA[I  was stuck in a problem that how to re use access token, once user has authenticated by Twitter (on call back URL). I got it working. There was problem in my understanding about request token vs access token. When user first time comes on call backed URL. I take request token and token secret [...]
Related posts:<ol>
<li><a href='http://www.pakzilla.com/2009/10/03/tutorial-java-based-twitter-app-on-google-app-engine/' rel='bookmark' title='Tutorial: Java based Twitter App on Google App Engine'>Tutorial: Java based Twitter App on Google App Engine</a></li>
<li><a href='http://www.pakzilla.com/2009/11/23/how-to-register-an-app-with-twitter/' rel='bookmark' title='How to register an app with Twitter'>How to register an app with Twitter</a></li>
<li><a href='http://www.pakzilla.com/2009/10/03/how-to-avoid-deadlineexceededexception-in-google-app-engine/' rel='bookmark' title='How to avoid DeadlineExceededException in Google App Engine'>How to avoid DeadlineExceededException in Google App Engine</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I  was stuck in a problem that how to re use access token, once user has authenticated by Twitter (on call back URL). I got it working. There was problem in my understanding about request token vs access token. When user first time comes on call backed URL. I take request token and token secret from session and prepare the access token. Here the place where I was confused.</p>
<p>Now if user presses the refresh button or you want to get user information again from twitter any where in your application. You need to use the access token and this method<strong> twitter.setOAuthAccessToken(String1, String2)</strong>. Because user has already been authenticated by Twitter. You can save this information in session.</p>
<pre class="brush: java; title: ; notranslate">
HttpSession session = request.getSession();

twitter.setOAuthConsumer(Constants.CONSUMER_KEY,Constants.CONSUMER_SECRET);

if (session.getAttribute(&quot;aToken&quot;) == null){
	// request token
	String token = (String) session.getAttribute(&quot;token&quot;);
	String tokenSecret = (String)session.getAttribute(&quot;tokenSecret&quot;);
	AccessToken accessToken =
		twitter.getOAuthAccessToken(token, tokenSecret);
	twitter.setOAuthAccessToken(accessToken);

	// save the access token, that are different from request token
	session.setAttribute(&quot;aToken&quot;, accessToken.getToken());
	session.setAttribute(&quot;aTokenSecret&quot;, accessToken.getTokenSecret());

}else{
	// use the access token to authenticate user whenever you want
	twitter.setOAuthAccessToken((String)session.getAttribute(&quot;aToken&quot;),
		(String)session.getAttribute(&quot;aTokenSecret&quot;));
}
User user = twitter.verifyCredentials();
</pre>
<p>If you are also developing some app by using Twitter4J API on Google App Engine. Please give feedback on it.</p>
<p><strong>Twitter4J Quick Tutorial:</strong> <a href="http://www.pakzilla.com/2009/10/03/tutorial-java-based-twitter-app-on-google-app-engine/">A quick tutorial on how to develop Twitter app by using Twitter4J on Google App Engine</a>.</p>
<p>Related posts:<ol>
<li><a href='http://www.pakzilla.com/2009/10/03/tutorial-java-based-twitter-app-on-google-app-engine/' rel='bookmark' title='Tutorial: Java based Twitter App on Google App Engine'>Tutorial: Java based Twitter App on Google App Engine</a></li>
<li><a href='http://www.pakzilla.com/2009/11/23/how-to-register-an-app-with-twitter/' rel='bookmark' title='How to register an app with Twitter'>How to register an app with Twitter</a></li>
<li><a href='http://www.pakzilla.com/2009/10/03/how-to-avoid-deadlineexceededexception-in-google-app-engine/' rel='bookmark' title='How to avoid DeadlineExceededException in Google App Engine'>How to avoid DeadlineExceededException in Google App Engine</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.pakzilla.com/2010/03/01/how-to-use-and-retain-twitter4j-oauth-access-token/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

