Monthly Archives: August 2006

Generating DHTML on the server vs client

DHTML, CSS and AJAX are all making people write more and more complex html code, ofcourse providing very good user experience. Dynamically displaying a UI control based on some user action can be achieved in two ways

1. By having the ui control pregenerated but hidden
2. By dynamically creating the dom necessary for the ui control and inserting it into the page’s dom.

The former can be done on the server side. The later, while the necessary components are still generated on the server side, the actual dom element construction and putting it into the page’s dom is done using JavaScript on the client side.

For most cases, I would recommend taking approach 1. This is because, tools like DOM Inspector seem to show only the initial dom when the page is loaded. Any subsequent manipulations to the DOM doesn’t seem to show in the DOM Inspector tree. So, debugging such changes could be really painful. Recently I had encountered one such senario for an AJAX application where the UI creation is happening on the client side using javascript.

Ofcourse, there may be cases where this can only happen on the client side. For example, to provide an ability to create any number of rows by clicking a “add another row” button, pregeneration of all the row regions before hand on the serverside is not feasible. So, that’s when the DOM manipulation on the client side will come handy.

So, unless you have this complexity, stick with pre-generating the UI elements on the serverside. You have a way to view the created HTML which makes it easy to debug.

Leave a comment

Filed under DHTML, javascript, js/dhtml, Tech - Tips

The components of a URL

Recently I asked a Java Web Component Developer certified person on what are the various components of a URL. The answer didn’t go that well, so let me summarize them here.

1) Protocol (http:// , https:// , ftp://)
2) Domain Name / IP Address (
3) Port Number (80 is default for http, 443 for https, so not needed to specify if the server is configured to the default ports)
4) Resource Path (/2006/08/27/the-components-of-a-url)

All the above makes it

In addition to the above 4 components, there are 2 more components.

5) The parameters (?abc=xyz&def=ijk). These provide parameters either entered by user or to navigate to another page with additional context
6) The anchor (#link2). This is the one that allows positioning the page in the browser to a particular section of the page. That is, using the html A element and the name and href attributes to create an anchor and reference it.

So, these 6 components together make the complete URL. All put together, there can be a url like

The above url doesn’t really exist, but it kind of explains that this will show all the spam comments received for the blogs in the last 3 months which could be below the non-spam comments. Ofcourse, the excellent service is that we can knock out spam using Akismet! But you get the point.

Books on web technology should cover some of these basic concepts.

Leave a comment

Filed under Technical Article

Rules Engine or Scripting Engine?

The question is which approach is better? The initial thought/requirement is that business users should be able to quickly adopt to changes in business and so, the rules engine provides them an easy way to quickly modify the business logic. But if only the business logic is so simple that one can simply change from + to – (markup vs discount). Those simple if then else rules soon become complex statements, blocks, built-in functions and soon a whole set of new language emerges and no longer in the reach of the business user to write them.

Perhaps when the scripting was not popular/well explored and thanks to the hype of AI in the earlier decades, the concept of rules engine came into existence. But with a better undersanding of scripting languages and the ability make them co-exist with compiled languages (c + tcl, java + beanshell a few examples), are rules engines lucrative anymore?

Yes, I do understand there is farward chaining, backward chaining, hybrid chaining and all that stuff and for that there are languages such as Prolog and Lisp that are very good at. But, deductive reasoning shouldn’t be confused with much of the business rules. I mean, it’s not like much of the auto-insurance policy rules have to go through a 10-level deep tree with 1000s of nodes before finding a solution. Or is it? I could be wrong, but hope not. Otherwise, it will be hard for me to compare and get the best deal :). So, I am not talking about knowledge based expert system type of rules engines.

I think the main issue is, going with hard-coded logic, it’s possible to do very complicated and optimized logic. Going with simple rules engines that are easy enough for business users, a few simple cases, perhaps even 70% of cases can be solved. But what about the rest? It’s the in-between cases that cause the problem. So, going with business rules perhaps is going to leave a gap.

However, using an embedded scripting engine, it’s probably possible to address the needs of both simple and medium complex problems. Infact, it may be possible to solve even the most complex problems, albiet a little slower (performance and not coding).

Frankly, if someone is telling that a business guy would know to write excel type of functions and branching logic such as IF(a,b,c), and can’t understand if(a) then b else c; then there is something fundamentally wrong in that assumption. I think it’s not the simple syntax that is the problem, but the overall logic of the code that makes it difficult.
And especially, if the data for the logic is in the database, the seamless way of fetching the necessary data, the sqls, the transaction and commits, in memory data vs database data and so on. These are the things that make things more complex, and not the simple syntax of rules.

All said and done about rules, Oracle 10g has an interesting rules engine that is event based. Pretty cool stuff and has more practical use than what conventional rules engines or programs can offer.

Those interested in scripting languages can further explore with these scripting languages books.

Leave a comment

Filed under Database, Questions, rules engine, Scripting

Date Arithmetic in Shell Scripts

I needed to be able to do date arithmetic do be able to do some stuff with log files. And I wanted to do this in shell script. Only then did I realize what a pain to deal with dates in shell scripts. After searching a bit, I found this link with various options. Many included using perl. I thought I would go with perl, but even there I didn’t exactly get what I needed (ofcourse, as perl is a full fledged programming language, it would have been lot less painful to do what I needed than in pure shell, but still).

My requirement is to start from a date and get the next 7 dates. So, the simple solution I came up with is to pre generate the dates and then use the shell script to get what I needed.

For example, “grep -A 7 ‘2006/07/04’ dates.txt” will give me the 7 dates starting from 2006/07/04, American Independence Day.

So, while the technique I am using does’t provide the real arithmetic capability, it solves my needs. And I think in a clever way. Oh, btw, I used BeanShell to pre-generate these dates.

If you are new to shell scripting, any of these shell scripting books may be useful.

Leave a comment

Filed under Shell Scripts

Online Search Privacy

Recently AOL leaked a 3 months worth of searches conducted by their users, supposedly by mistake. Even though the usernames are not given out in the logs, there is a lot of criticism based on this article about how it became possible to derive the identify of a person based on the searches she conducted.

In case of AOL, the searches are tied back to the individual user based on the AOL account. Since Google doesn’t have subscription like AOL, is it safe to assume your privacy is safe with Google? Not so if you are using Gmail as well. Why? Because, when you login to Gmail and keep it open all the time like I do, then, everytime you do a search, Google would know that it’s you (with a particular gmail email address), that’s doing the search! And that’s scary. Isn’t it?

All the people keep complaining about this privacy issue. One way this could be resolved is, if you can have two separate instances of Firefox each running as a separte process and one not knowing about the cookies of the other. Perhaps due to various technical reasons this is not possible, but where there is a will, there is a way. Isn’t it?

On the otherhand, even if that was possible, would you want to keep switching between two separate browsers? That’s the whole reason why we all love the Firefox’s tabbed browsing functionality in the first place.

So, what can be done to be able to browse in a single browser and yet protect your privacy against Google? Or for that matter any other company that can track your usage of their free service based on your logging into another of their service?

I think, I found a solution. It’s basically the IE Tab plugin I talked about in my previous blog. Here is what you can do.

1. Get Firefox if you already don’t have one and install it.
2. Then download the “IE Tab” plugin mentioned above and install it, restart the browser.
3. Now, go to and switch it to IE by clicking the “IE Tab”s icon at the bottom on the status bar.
4. Login to Gmail.
5. Now, open another tab and happly keep searching the web, and Google wouldn’t get your cookie of their gmail to track you.

How do you know if it’s working? You will notice that while in the past, when you visited Google’s homepage to search, you would see “Logout” link, now you will start seeing “Sign In” link. Google no longer knows that you logged in as IE’s cookie base is different from Firefox’s.

Of course, they can still use the IP address of your machine to try to corelate. But it’s a little less accurate than relating your searches to precisely you!

1 Comment

Filed under Gmail, Google Search, Privacy, Tech - Tips

IE in Firefox

WINE allows running windows apps in Linux. And that’s cool. What else is cool?

This “IE Tab” Add-on. With the click of a little icon in the status bar, you can switch viewing a page between Firefox and IE. That, is definitely a very cool add-on.

Leave a comment

Filed under Internet Explorer, Tech - Tips

A good jdbc based database explorer

I wanted to incorporate Derby into one of my projects and instead of using their ij command line tool, I wanted to use a UI to explore the objects and data. For this, I tried searching for a good tool.

I found this link on Oreilly

But finally I settled with executequery

So far it’s been good experience using it. If you are new to jdbc, more can be learned from these jdbc books.


Filed under Database, JDBC

Why jdbc needs a special api to set nulls?

While Hibernate and other persistence frameworks are good, there are times why one wants to stick to the plain jdbc. One pain point with using jdbc is setting the parameters. People use various paradims including stmt.setInteger(i++,value); to keep track of the index. However, with JDK 1.5 supporting varargs, one can write a utility function like

public void update(PreparedStatement pstmt,Object ... vals) {

for(int i=0;i<i++) {

But if one of the values is a null, then the above doesn’t seem to work. One has to explicitly use stmt.setNull(index,type) api. Not sure why setting a bind to null requires specifying the data type.

Leave a comment

Filed under JDBC