Showing posts from 2006

Java 5 Feature: An intro to foreach

Looping is a control structure that has been around ever since we started programming. The good old syntax for looping that you would have used most often is:

String[] messages = {"Hello", "Greetings", "Thanks"};
var length = messages.length;
var int i = 0;
for(i = 0; i < length; i++){

What if you want to iterate over a collection, like ArrayList? We will do something like:

Iterator iter = lst.iterator();
for(;iter.hasNext();) {

The foreach was introduced to avoid introduction of any new keywords. The foreach introduced in Java 5 simplifies looping further. Let’s take a look at an example of how we can use the new way to loop:

for (String msg : messages) {

You would read
for (String msg : messages)
as "foreach String msg in messages". Within the loop of foreach, msg represents a String element within the array String[].
Instead of inventing another keywo…

Java 5 Feature: An intro to Autoboxing

With Java 5 (or Java 1.5 or JSE 5.0 or Java J2SE 5.0 or JDK 1.5), a new feature called Autoboxing has been introduced to the language. it is the automatic conversion of the primitives and wrapper objects.
Boxing is to place a primitive data-type within an object so that the primitive can be used like an object. For example, a List, prior to JDK 1.5, can't store primitive data types. So, to store int type data in a List, a manual boxing was required (i.e from int to integer). Similarly, to retrieve the data back, an unboxing process was required to convert Integer back to int.
Autoboxing is the term for treating a primitive type as an object type. The compiler automatically supplies the extra code needed to perform the type conversion. For example, in JDK 1.5, it now allows the programmer to create an ArrayList of ints. This does not contradict what was said above for List: the ArrayList still only lists objects, and it cannot list primitive types. But now, when Java expects an objec…

Google Browser Sync

Google Browser Sync for Firefox is an extension that continuously synchronizes your browser settings - including bookmarks, history, persistent cookies, and saved passwords - across your computers. It also allows you to restore open tabs and windows across different machines and browser sessions.
Please note: Google Browser Sync must update your browser settings whenever you start Firefox. This will increase the start-up time of Firefox (the time between clicking on the Firefox icon and loading your start page) - please bear with us as we work to decrease this delay.

How to Use
To use Google Browser Sync, simply install and configure the extension on all computers for which you'd like your browser settings automatically kept in sync. Even if you only install Browser Sync on a single computer, you can use it to backup your browser settings and to restore your open tabs and windows across browser sessions.

Configuring your computers
After successfully downloading and installing the exten…

To Ruby From Java - Similarities and Differences

Came through this interesting post comparing Java with Ruby. Java is mature. It's tested. And it's fast (contrary to what the anti-Java crowd may still claim). It's also quite verbose. Going from Java to Ruby, expect your code size to shrink down considerably. You can also expect it to take less time to knock together quick prototypes.SimilaritiesAs with Java, in Ruby... Memory is managed for you via a garbage collector.Objects are strongly typed.There are public, private, and protected methods.There are embedded doc tools (Ruby's is called RDoc). The docs enerated by RDoc look very similar to those generated by javadoc.DifferencesUlike Java, in Ruby... You don't need to compile your code. You just run it directly.There are different GUI toolkits. Ruby users can try WxRuby, FXRuby, Ruby-GNOME2, or the bundled-in Ruby Tk for example.You use the end keyword after defining things like classes, instead of having to put braces around blocks of code.You have require …

HtmlUnit - unit testing framework for web applications

HtmlUnit is a java unit testing framework for testing web based applications. It is similar in concept to httpunit but is very different in implementation. Which one is better for you depends on how you like to write your tests.
HttpUnit models the http protocol so you deal with request and response objects. HtmlUnit on the other hand, models the returned document so that you deal with pages and forms and tables.

HtmlUnit is not a generic unit testing framework. It is specifically a way to simulate a browser for testing purposes and is intended to be used within another testing framework such as JUnit.

Support for the HTTP and HTTPS protocols. ( JSSE must be in your classpath in order to use HTTPS support)
Support for cookies
Ability to specify whether failing responses from the server should throw exceptions or should be returned as pages of the appropriate type (based on content type)
Support for submit methods POST and GET
Ability to customize the request headers being sent to th…

Helipad - The flexible web notepad

Helipad is a web-based tool, which means you can use it wherever you can get online.

Since Helipad is a hosted application, we do all the boring stuff: backup documents, maintain security, upgrade software, while you're left to do the most important thing: write.
Write notes and organize them with tagsCreate and maintain to-do listsDraft documents on any computer or phone with Internet accessShare your work with others
Unobtrusive auto-save: set a timer to save automatically so youdon't lose your workOrganize your documents with tagsQuickly find documents with a live-search on every pageCustomize your Helipad with themes and pluginsShare your documents with friendsPrepare documents for print by changing fonts
Get more out of Helipad
Helipad works with popular phone web browsers.Your notes look great printed from Helipad.Developers can get more out of Helipad by using the API, or by writing add-ons.


DropBoks is a little website that allows you to securely upload and download your files as you please. No bells, no whistles, just an easy and quick way to store your files online.Each account has 1 GB of storage space available. You can upload and download files (any format) as large as 50 MB.How are we able to keep DropBoks free? We have found that when you offer a
valuable service that is extremely simple to use, folks have no problem making a
small donation. This has covered our costs since day one!

meebo - Browser based IM is a website for instant messaging from absolutely anywhere. Whether you're at home, on campus, at work, or traveling foreign lands, hop over to on any computer to access all of your buddies (on AIM, Yahoo!, MSN, Google Talk, ICQ and Jabber) and chat with them, no downloads or installs required, for free!

Common J2EE Design Patterns

There are a common set of design patterns for the J2EE platform.
Intercepting filter--This pattern applies to request pre- and post-processing of request. It applies additional services needed to process a request. For example, an intercepting filter such as a servlet filter may handle all incoming requests to the Web site and provide a central mechanism for authorization. View helper--A view helper encapsulates the presentation and data access logic portions of a view, thus refining the view and keeping it simpler. Presentation logic concerns formatting data for display on a page, while data access logic involves retrieving data.
View helpers are often JSP tags for rendering or representing data and JavaBeans for retrieving data. Composite view--This pattern makes view presentation more manageable by creating a template to handle common page elements for a view. Often, Web pages contain a combination of dynamic content and static elements, such as a header, footer, logo, background, an…

Soft skills for software engineers

Software Development Philosophies

This is an incomplete list of approaches, styles, or philosophies in software development.
Agile software development Agile Unified Process (AUP) Open Unified Process Best practice Cathedral and the Bazaar Constructionist design methodology (CDM) Design-driven development (D3) Dynamic Systems Development Method (DSDM) Extreme Programming (XP) Iterative and incremental development KISS principle (Keep It Simple, Stupid) MIT approach, see Worse is better Open Unified Process Quick-and-dirty Rational Unified Process (RUP) Scrum (management) Spiral model Test-driven development (TDD) Unified Process Waterfall model Worse is better (New Jersey style) You Ain't Gonna Need It (YAGNI)
From Wikipedia

Developing applications with Facelets, JSF, and JSP

Dr. Xinyu Lu has published an article on giving an overview of the differences between developing webapps using JSP and JSTL tags, and JSF. This article introduces a rich list of useful tips to help developers smoothly transition from the old-fashioned JSP/servlet programming to the new JSF-style programming. It clarifies the issues and confusion developers may encounter, and promotes best practices and methodologies to simplify web development, improve code reuse, and make source code more designer-friendly, as well as easy-to-maintain.

JavaServer Faces (JSF) is a server-side user interface component framework for Java-based web applications. As a standard web development technology, JSF 1.2 is encapsulated as part of the latest Java EE 5 specification. JSF promotes a component-based, event-driven UI development methodology, independent from any mark-up language, protocol, or client device. Inspired by MVC frameworks like Struts, the JSF API has built-in support for internati…

Simultaneous posting on Blogger and MSN Spaces

Now you can easily post your Blogger post on MSN Spaces without doing any cut-copy-paste. The trick is very simple and anybody can use it in no time.

Sign into your MSN Spaces and access Settings > EMail Settings. Turn on e-mail publishing. Specify up-to-three email addresses you want to use to publish blog entries. Enter your Blogger Mail-to-Blogger Address here (BloggerDashboard > Settings > EMail) in one of them.Choose a secret word. (Let us say it is 'agent007'). This secret word is combined with your space name (Lets say it is mymsnspace) to form a special e-mail address ( that only you can use to publish entries to your space. Access Settings tabs in you Blogger Dashboard in another window. There is a textfield named BlogSend Address. Here provide an email address to have your blog mailed to whenever you publish it. Enter your special e-mail address that MSN Spaces has created for you (…

How can i prevent Browser from Caching the Page content?

Before sending the data to the browser, use the following code:
response.setHeader ("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
This also helps in case, when user should not be able to see previous pages by clicking the Back button in the browser.

Can an icon be published on the left side of the URL in the address bar?

Create an icon called favicon.ico and place that in the root of the website. You can also link to it using this: <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> Source:

JBoss - The Basics

This is not for the experienced JBoss application server user. It is meant to give the JBoss beginner the basics to running and deploying applications to JBoss 4.0.3 SP1.
JBoss LayoutJBoss is easy to understand if you know the way the directories are setup and how to work with them. First everything you will do to JBoss is in the install directory. bin directoryThe most important one here is the run.bat or This will run the application server and display debug and information messages to the user in the session it is started in. To start JBoss simply use the run command from this directory. To stop the server do a CTRL-C in the session it was started in. There are also some other files there but this is the basics only so I will not discuss them. lib directoryThis is the "root" server lib directory. You don't usually have to nor want to do anything with these libs. server directoryThis is where the directories for the server instances are. This is wh…

[Humor] Compensation

How are you compensated in the Organization for the good work? Is it one of these forms ;)

Javascript plugin for Eclipse

I waas looking for a Javascript editor and came across JSEclipse plugin from Interakt. Its a beautiful plugin and even has a all-features-enabled free version :).

The best things I like about JSEclipse are:
Code completion for JavaScript function and classes. Code completion for JavaDoc. Function and class names are displayed in the Outlinepanel for the currently open file. Open declaration i.e. the famous F3 functionality Error reporting Warning reporting Code wrapSupport for major JavaScript libraries
Code completion uses Rhino for better accuracy
Use of JSDoc and inline parameter comments to detect parameter type
Suggest parameters to be filled
Project dependent code completion
Reads all classes in current project
Reads classes in currently opened files
Scan current file for words
Reads XML files for class definitions
Add your own XML with class definitions
However, it works on Eclipse 3.1.x versions only. I have multiple Eclipse installations. It didnt work on Eclipse 3.0 ("Edito…

Google Web Toolkit for building AJAX apps in Java

Google has introduced a toolkit for building AJAX applications in Java, though its in beta. It has also supplied some sample applications with the kit.
Google Web Toolkit (GWT) is a Java software development framework that makes writing AJAX applications like Google Maps and Gmail easy for developers who don't speak browser quirks as a second language. Writing dynamic web applications today is a tedious and error-prone process; you spend 90% of your time working around subtle incompatabilities between web browsers and platforms, and JavaScript's lack of modularity makes sharing, testing, and reusing AJAX components difficult and fragile.GWT lets you avoid many of these headaches while offering your users the same dynamic, standards-compliant experience. You write your front end in the Java programming language, and the GWT compiler converts your Java classes to browser-compliant JavaScript and HTML.I plan to explore GWT for the next couple of days and then would be writing on t…

Stop Whining...Dilbert style :)


[Humor] Progressive HR Policies

Dear Staff,

Please be advised that there are NEW rules and regulations implemented to raise the efficiency of our firm.

It is advised that you come to work driving a car according to your salary. If we see you driving a Honda, we assume you are doing well financially and therefore you do not need a raise.

If you drive a 10 year old car or taking public transportation, we assume you must have lots of savings therefore you do not need a raise.

If you drive a Pickup, you are right where you need to be and therefore you do not need a raise.

Annual Leave
Each employee will receive 52 Annual Leave days a year (Wooow!).
They are called Sunday.

Skinny people get 30 minutes for lunch as they need to eat more so that they can look healthy.
Normal size people get 15 minutes for lunch to get a balanced meal to maintain their average figure.
Fat people get 5 minutes for lunch, because that's all the time needed to drink a Slim Fast and take a diet pill.

We w…

Female Software Professionals

Received this 'source code' from a friend. Found quite interesting. Just reproducing here in good humor. No offences. No gender biases. Just a positively humorous entry.

class Indian_Bachelor_female_professional
double styles;
short skirts;
long time_to_understand_problems;
float mind;
void knowledge();
char non_co_operative;

class Married_female_Software_Professional {
double weight;
short tempered;
long gossips;
float hopes;
void work();
char unstable;

class Female_Engaged_software_professional {
double time_on_phone;
short attention_on_work;
long boast;
float on_cloud_nine;
void understanding();
char edgy;

class Newly_Married_software_professional {
double dinner_invitations;
short time_at_work;
long lunch_breaks;
float talks;
void bank_balance();
char hen_pecked;

class husband_wife_software_professional {
double income;
short temper;
long time_no_see;
float new_software_company;

Working too long in the same Company

What type r u ;) [Received in an email]

[Humor]Acronyms and Abbreviations

New meaning to the names of a few IT companies:

No hard feelings. Just a positively humorous attempt!
AT&T : All Troubles & TerribleBAAN : Beggars Association and NerdsBFL : Brainwash First and Let them goC-DOT : Coffee During Office TimingsCMC : Coffee, Meals and ComfortDEC : Drifting & Exhausted ComputersDELL : Deplorable Equipment & lacklusterHCL : Hidden Costs & LossesHUGHES : Highly Useless Graduates Hired for Eating and SleepingIBM : Implicitly Boring MachinesINFOSYS :Inferior Offline SystemsNIIT : Not Interested in ITORACLE : On-line Romance And Chatting with Lady EmployeesPARAM : Puzzled And Ridiculous Array of MicroprocessorsPATNI: Pathetic Appraisal Techniques, No IncrementsPSI : Peculiar Symptoms of IndiaSATYAM : Sad And Tired Yelling Away MadlyTCS : Totally Confusing SolutionsTISL : Totally Inconsistent Systems LtdWIPRO : Weak Input, Poor & Rubbish Output

Can you create folders with these names?

Can you create folders in your Windows environment with these names:
AuxConNulDo you why? May be 'reserved words'?!!!

Looking for info for Web Hosting

I am planning to have a domain for my blog. However, I have no experience of having a separate domain and getting it hosted. So, I would like to know how to proceed on that. I am in India, and would prefer a Company that accepts payment in Indian Rupees. Also, while selecting a company for hosting the sites, which facilities/features I should see e.g. sub-domains, email ids, storage etc. Also, what are the popular blog softwares required? Plz share your experiences.

A funny take on a True Programmer!!!

A Not-To-Do List

Has form data changed?

I recently came across a situation where it was required that form should be submitted only if there was any change of data in the form-fields, and there were some 90 fields in the form! So, what to do? Checking 90 fields manually was simply out of question for me, as for this, I had to take care of their initial value (when page was rendered). So, I decided to dig a deep into Javascript and look for some sort of solution there. And it was their already!!!
For every HTML control, we know there is an ID, name, type and value attached to it. What is not known to all is that there is a 'defaultValue' as well for each control. So, using this 'default' behavior, we can check if there is a change in form-data.

* Checks if the form data is changed
* @ param - none
* @returns boolean
function isFormChanged() {
var formNo=document.forms.length;
var flag = true;
for (j=0;j var max = document.forms[j].elements.length;
for(var i=0; i< max; i++) {
if (document.f…