Source: www.jroller.com/rss/debashish/weblog

Null Pointer
A brilliant (sic) coalesce of Technology (where the emphasis is on Java), Internet, Blogging, Indic-blogging, current-affairs, politics, entertainment industry and topics that concern India.


Null Pointer moves to its own home

I recently moved to my own domain and after migrating the blog to Wordpress (read this post to know how I managed to do that) I simply dropped a note here at JRoller to let know my readers who still come here. For the email subscribers I simply changed the feed URL. Today it struck me that some also read me through newsreaders and these guys would probably never know unless I tell them, through the feed, about the migration. So a change of mind and another post that must happens to be the last one at JRoller.



Null Pointer now resides at http://nullpointer.debashish.com. Bloglines subscribers can click here to subscribe to the feed. For others, the blog has a RSS as well as an Atom Feed, please subscribe to the one you like. My hindi blog NuktaChini may be read here.



Thanks a lot! Hope to see you at my new home.



Make your own Java newsreader

XML feeds are the way today to keep a tab on what?s happening in the blogosphere as well as to know about site updates and new additions. I had heard about two popular open source feature-rich Java APIs to deal with the feeds, Rome and Informa but could never really savor them. For one of my own sites where I, sort of hand-built the aggregator as Myjavaserevr does not allow deploying external JARs or Taglibs I did not get any chance to play with these APIs. So when I got some opportunity it was imperative that I tried them.

The following is a very elementary example of using the two news aggregation libraries that imitates a newsreader. The examples, as I said, are pretty basic and they would make a hit to the specified Feed URL every time you call the JSPs. The code snippets are not meant to demonstrate good coding practice.

Both the libraries support almost all versions of RSS, RDF and Atom and features such as dynamic discovery of feed format. Feature wise probably Informa has an upper hand (it supports OPML, recognizes the Enclosure element making it suitable to comprehend Podcast feeds and can be configured to use a persistence mechanism built over Hibernate) but what it lacks is availability of documents. There are no primers at the site and the code is very poorly commented making the Javadocs difficult to come to pace quickly. The two Java.net articles that I could, Google have been outdated, as I used the 0.6.5 version of the library. Rome, on the other hand, has very nice documentation available at its site, complete with code examples. Many desirable features are unfortunately still on the TODO list. While I have not investigated them, there are a number of sub-projects based on both Rome and Informa, for example: there is a JSP Tag library based on Informa. There is a short review of various libraries here but I guess much stuff on Informa is not relevant now since its latest release.

I am not mincing my words when I say that each API has its own strengths, Informa library is pretty bulky but supports OPML while Rome has a wider support for all kind of XML feeds and has a pluggable architecture. The good thing about these APIs is that they pretty much offer you everything that you may want to do with feeds, reading, generating your own, and creating a digest from multiple feeds and so on.

To run these JSPs, needless to say, you would need to download Informa and Rome libraries. I ran these on jakarta-tomcat-5.0.28 / j2sdk1.4.2_06 and the only dependency I was missing was the JDOM jar that Rome needs.

A bare-minimum Newsreader based on Informa:

<%@page import="java.net.URL, de.nava.informa.core.ChannelFormat, de.nava.informa.core.ItemIF, de.nava.informa.parsers.FeedParser, de.nava.informa.core.ChannelIF, de.nava.informa.impl.basic.ChannelBuilder, de.nava.informa.core.ItemEnclosureIF, java.util.*" contentType="text/html;charset=UTF-8" %> <% String url = request.getParameter("url"); if (url != null && !url.trim().equals("")) { try { ChannelIF channel = FeedParser.parse(new ChannelBuilder(), new URL(url)); %> <h3>New posts from: <a href="<%=channel.getSite()%>" target="_blank"><%=channel.getTitle()%></a> by <%=channel.getCreator()%></h3> <% for (Iterator it = channel.getItems().iterator(); it.hasNext (); ) { ItemIF item = (ItemIF)it.next(); ItemEnclosureIF enclosure = item.getEnclosure(); %> <h4><a href="<%=item.getLink()%>"><%=item.getTitle()%></a></h4> <font size="1" color="brown">[Published on <%=item.getDate()%>]</font> <p><%=item.getDescription()%></p> <% if(enclosure != null){ %> <p><a href="<%=enclosure.getLocation()%>">Enclosure</a> [<%=enclosure.getType()%>, <%=Math.floor(enclosure.getLength()/1000000)%> MB]</p> <% } } } catch (Exception ex) { ex.printStackTrace(); %>Sorry, error occurred while fetching posts for url: <%=url%><% } } else { %>Please provide a feed URL.<% } %>

A bare-minimum Newsreader based on Rome:

<%@page import="java.net.URL, com.sun.syndication.feed.synd.SyndFeed, com.sun.syndication.io.SyndFeedInput, com.sun.syndication.feed.synd.SyndEntry, com.sun.syndication.io.XmlReader, java.util.*" contentType="text/html;charset=UTF-8" %> <% String url = request.getParameter("url"); if (url != null && !url.trim().equals("")) { try { URL feedUrl = new URL(url); SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(feedUrl)); List al = feed.getEntries(); %> <h3>New posts from: <a href="<%=feed.getUri()%>" target="_blank"><%=feed.getTitle()%></a> by <%=feed.getAuthor()%></h3> <% for (Iterator it = al.iterator (); it.hasNext (); ) { SyndEntry entry = (SyndEntry) it.next (); %> <h4><a href="<%=entry.getUri()%>"><%=entry.getTitle()%></a></h4> <font size="1" color="brown">[Published on <%=entry.getPublishedDate()%>]</font> <p><%=entry.getDescription().getValue()%></p> <% } } catch (Exception ex) { ex.printStackTrace(); %>Sorry, error occurred while fetching posts for url: <%=url%><% } } else { %>Please provide a feed URL.<% } %>

Piping problem

I recently had a task wherein I was required to call few Perl routines from inside my Java class. You must be saying, waht's the big deal? Runtime.exec is what one needs. You are dead right, this comes to rescue when ones needs to call a non-Java process or an executable. With this, I was able to call most of the said routines, except a few that were using "Piping". Now, a pipe is a one-way I/O channel which can transfer a stream of bytes from one process to another, meaning that one processes's standard output serves as a pipe to another program; anything you print to STDOUT will be standard input for the other process.

With a piped routine call as follows, only routine1 got exccuted and routine2 didn't.

./routine1.pl param1 | ./routine2.pl -directory param2

Googling revealed that people were facing problems too and I had no clue as to how I could use the Standard output from the Process object to feed to second routine.

I finally found the solution here, like the light at the end of tunnel. As the article says, Runtime.exec invokes actual executable binary programs. Syntax such as pipe (|) and > are part of a particular command processor, and are only understood by that processor. So in such calls, the command preceding the pipe is executed, but the rest of the shell command is not. Moreover, invoking the process with single string argument, say as "sh -c './routine1.pl param1 | ./routine2.pl -directory param2'" doesn't work because the String passed to exec method is split apart into tokens without caring for the single inner quotes.

Without further ado, let me reveal that invoking the process as follows is what works:

String param = "./routine1.pl param1 | ./routine2.pl -directory param2"; Runtime runtime = Runtime.getRuntime(); String[] args = new String[]{"sh", "-c", param}; Process p = runtime.exec(args);

Blogger block

Charu refers to an article on how to deal with the blogger burnout, a term I came to terms with when Jivha quit blogging. For me it has been more the case of Blogger block rather than burnout. I have never been a zealous blogger anyway but few months back I at least would right twice/thrice a week, it is still twice or thrice but the weeks have turned into months. A blog-friend, who just would not have Null Pointer on his blogroll ;), tauntingly observed recently, "I like your blog but it would be better if you atleast have one post a week instead of one a month". Some write to me enquiring if I have quit blogging, and while I am reading all those blogs regularly, I am often ashamed to find a referrer log entry from a reader who visited my blog expecting some new post but (perhaps) went away perturbed. I worry if s/he would ever come back again.

A thing that prevents me from blogging regularly is absence of net connectivity at home. Then the recent happenings at the personal front are to be blamed too. Blogging at work is definitely awkward, your colleagues keep staring at your monitor and are not content to ask "Yeh kya hai?"; preparing a post especially in Hindi (and I am very poor at punching Hindi on Takhti) seems more heinous than looking a porno pop-up that shockingly appeared from an innocent looking site. During the day I must have been thinking at least a dozen times to blog about this and blog about that, but I am too lazy to jot it down immediately. Then it slips from your mind and poof, the slate is clean again. Now, I never have been in the habit of posting a link with a short comment, an advice given in the article that I just can't follow, most of my posts are lengthy, some are notoriously so.

So I don't think I (and the readers) have much choice really except that I don't care a damn about those staring eyeballs and don't feel ashamed in jotting a short link post instead of waiting to post longer ones and then not posting at all.



Happy 2006

Null Pointer wishes all it's readers a very happy and prosperous new year!



Reading blogs with an Opinmind

Thousands of issues are raised everyday in blogs and among all those heavily opinionated posts, sometimes you wish you could get to know about both sides of a story, effortlessly. Opinmind is a new blog-search engine that does precisely that. It displays both the "positive" and "negative" opinions on the searched topic, with a "sentimeter" that gauges the mood of the web on the searched topic, thankfully with "no editorial judgment".

Very innovative! And if don't wanna take my word for it, try this search.



Customized widgets with Google Module API

Google has expanded on this idea of customization of their homepage and now you can come-up with your own custom widgets for the whole world to use. Within days of Yahoo releasing version three of its widgets, Google has made its API to make modules public for developers to create modules, possibly host them at Google base and view the content on their customized Google homepage. There are many samples to play with and a detailed guide to explore more. This place is sure going to swell in time to come.

While they may seem same, conceptually Yahoo?s widgets and Google?s modules are pretty different, Google?s modules, primarily XML, are pretty much meant for inline rendering of content on its own homepage, Yahoo?s widgets, based on Yahoo! Widget Engine or Konfabulator, may be more portable I suppose.



Indic Blogger Awards

Raman informs that Microsoft's BhashaIndia, a portal on Indic language computing featuring the Microsoft solutions, is coming up with its "Indic Blogger Award" for blogs in Indian languages. Boasting of eight categories with 11 Indic languages in the fray this sure will provide the necessary boost to bloggers like us. Wonder if they owe the idea to the Indibloggies that is the first Indian weblog awards to concentrate on Indic blogs also. Microsoft is also sponsoring two prizes at the Indibloggies 2005.

The Indibloggies 2005 edition BTW has started with a whopping 28 member Jury to rate the nominated blogs. Nominations would be done using Delicious this year and a detailed notification will follow on 15 Dec at the Indibloggies website. Like last year, there has been a tremendous response from the sponsors with prizes worth more than INR 50000 to be claimed.



Delicious, says Yahoo!

Yahoo has acquired del.icio.us, the pioneering social bookmarking service made by Joshua Schachter, an unpredictable yet great move for the giant after the Flicker buy. With Yahoo hopefully integrating and augmenting the services, it seems tagging would now be everywhere. What a tasty way to end the year!



What were they thinking?

Is what I think when I see the keyword referrers to my blog. Savor few I encountered offlate:any company they have been treating their employees unethicallycostume for anchors of aaj tak channelIs abhigyan prakash still with ndtv today?funny interviews about atal bihari vajpayee in hindifind any company they have been treating their employees unethically and give the name of this companyisraeli "married to an indian"how to enter in mission one crore programme by sahara tv



Newsfeed display by CaRP

Software: Programming
See Software in Open Directory
Find related sites in Open Directory

Return to News Feeds Home Page
My Sites